Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The current implementation of authorization is too cumbersome and requires implementing a big amount of boilerplate code. This changes inroduce `Authorizer` interface, which is responsible for authorizing users. It's a replacement for specifiying a function for creating a new secure context. Advantage is stem from the fact that users only implement business logic for authorization and nothing more. Also this type of API is similar to `Authenticator`, which makes API more consistent.
- Loading branch information
Showing
13 changed files
with
134 additions
and
179 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
20 changes: 20 additions & 0 deletions
20
dropwizard-auth/src/main/java/io/dropwizard/auth/Authorizer.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
package io.dropwizard.auth; | |||
|
|||
import java.security.Principal; | |||
|
|||
/** | |||
* An interface for classes which authorize principal objects. | |||
* | |||
* @param <P> the type of principals | |||
*/ | |||
public interface Authorizer<P extends Principal> { | |||
|
|||
/** | |||
* Decides if access is granted for the given principal in the given role. | |||
* | |||
* @param principal a {@link Principal} object, representing a user | |||
* @param role a user role | |||
* @return {@code true}, if the access is granted, {@code false otherwise} | |||
*/ | |||
boolean authorize(P principal, String role); | |||
} |
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
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
Oops, something went wrong.