You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One sample valid request: `curl -H 'Authorization: Bearer my-bearer-token' 'http://localhost:8080/api/example/test'`
213
+
214
+
### Resource authorization based on annotation
215
+
This feature is provided `AuthorizationSecurityFeature` and works with any authentication system.
216
+
For example using bearer auth:
217
+
- In the `JerseyConfigProvider` file, declare the feature with the annotation used for resource identification: `config.register(new BearerAuthenticator("my-bearer-token").toAuthorizationFeature(BearerRestricted.class));`
218
+
- In the `JerseyConfigProvider` file, register if needed the annotation used in the `RequireExplicitAccessControlFeature`: `config.register(RequireExplicitAccessControlFeature.accessControlAnnotations(PublicApi.class, BearerRestricted.class));`
219
+
- Use the annotation in a resource definition:
220
+
```java
221
+
@Path("/example")
222
+
@Tag(name="example", description="Manage exemple web-services")
223
+
@Consumes(MediaType.APPLICATION_JSON)
224
+
@Produces(MediaType.APPLICATION_JSON)
225
+
// The new annotation that will ensure the authorization process before granting access
@@ -62,13 +61,17 @@ public static BasicAuthenticator<String> fromSingleCredentials(String singleUser
62
61
// API
63
62
64
63
/**
65
-
* Provide an {@link AuthorizationVerifier} from the basic authenticator to provide annotation based request authorization using {@link com.coreoz.plume.jersey.security.AuthorizationSecurityFeature}
66
-
* @param annotation The annotation that will be used to identify resources that must be authorized. For example {@link BasicRestricted} can be used if it is not already used in the project for another authorization system
67
-
* @return The basic authenticator corresponding {@link AuthorizationVerifier}
68
-
* @param <A> The annotation type
64
+
* Provide a {@link AuthorizationSecurityFeature} from the bearer basic that can be used in Jersey
65
+
* to provide authentication on annotated resources.
66
+
* @param basicAnnotation The annotation that will be used to identify resources that must be authorized. For example {@link BasicRestricted} can be used if it is not already used in the project for another authorization system
67
+
* @return The corresponding {@link AuthorizationSecurityFeature}
68
+
* @param <A> The annotation type used to identify required basic authenticated resources
69
69
*/
70
-
public <AextendsAnnotation> AuthorizationVerifier<A> toAuthorizationVerifier(Aannotation) {
@@ -25,20 +24,25 @@ public BearerAuthenticator(String bearerToken) {
25
24
}
26
25
27
26
/**
28
-
* Provide an {@link AuthorizationVerifier} from the bearer authenticator to provide annotation based request authorization using {@link com.coreoz.plume.jersey.security.AuthorizationSecurityFeature}
29
-
* @param annotation The annotation that will be used to identify resources that must be authorized. For example {@link BasicRestricted} can be used if it is not already used in the project for another authorization system
30
-
* @return The basic authenticator corresponding {@link AuthorizationVerifier}
31
-
* @param <A> The annotation type
27
+
* Provide a {@link AuthorizationSecurityFeature} from the bearer authenticator that can be used in Jersey
28
+
* to provide authentication on annotated resources.
29
+
* @param bearerAnnotation The annotation that will be used to identify resources that must be authorized. For example {@link BearerRestricted} can be used if it is not already used in the project for another authorization system
30
+
* @return The corresponding {@link AuthorizationSecurityFeature}
31
+
* @param <A> The annotation type used to identify required bearer authenticated resources
32
32
*/
33
-
public <AextendsAnnotation> AuthorizationVerifier<A> toAuthorizationVerifier(Aannotation) {
0 commit comments