-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit access to API endpoints that require logged in users to CRUD on…
…ly their information (#90) Limit access to API endpoints when trying to do allowed actions but not for your user, but others. If the id of the user sent as the Path Parameter does not match the one in the authentication token, then a 403 Forbidden is returned. It does not make sense to return a 404 Not Found because the user knows the resource exists
- Loading branch information
Showing
7 changed files
with
92 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
webapp/src/main/java/ar/edu/itba/paw/webapp/auth/LoggedUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ar.edu.itba.paw.webapp.auth; | ||
|
||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
import java.util.Collection; | ||
|
||
public class LoggedUser { | ||
|
||
public static int getDni() { | ||
return Integer.valueOf(SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString()); | ||
} | ||
|
||
public static Collection<? extends GrantedAuthority> getAuthorities() { | ||
return SecurityContextHolder.getContext().getAuthentication().getAuthorities(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters