Skip navigation links

Package com.atlassian.asap.core.server.jersey

Jersey 2 adapter for ASAP

See: Description

Package com.atlassian.asap.core.server.jersey Description

Jersey 2 adapter for ASAP

This adapter works a bit differently than other adapters by requiring the Asap annotation to be placed on a resource package, class, or method level to trigger the ASAP authentication and authorization. The JwtParam annotation is then used for optional Jwt parameter injection.

Installation

To install the authentication and authorization filters, you need to add a few singletons to your Jersey configuration:

  jerseyConfig.register(AuthenticationRequestFilter.newInstance(AUDIENCE, PUBLIC_KEY_URL));
  jerseyConfig.register(AuthorizationRequestFilter.newInstance());
  jerseyConfig.register(new JwtParamBinder());
 

These filters will create, validate, and authorize the jwt token for the request, while the JwtParamBinder will handle injection for the JwtParam annotation. Technically, the JwtParamBinder instance is optional.

Usage

To add ASAP authenticate and authorization to your resource, just add the Asap annotation to your resource package, class, or method. This is an example of adding it on a class level:

  @Asap(authorizedSubjects = "mysubject")
  public class MyResource {
      void viewFoo() {}
  }
 

Environment variable configuration

To configure the subject and issuer whitelists via environment variables instead of hard-coding the values into annotations, you can instead create the AuthorizationRequestFilter instance like so:
     new AuthorizationRequestFilter(new EmptyBodyFailureHandler(), AsapValidator.newEnvironmentVariablesValidator());
 
The default environment variables are found on AsapValidator.EnvironmentVariablesWhitelistProvider.
Skip navigation links

Copyright © 2017 Atlassian. All rights reserved.