NationalSecurityAgency/datawave-authorization-service

Java

8

218 commits

updated Feb 20, 2025

See the code

README

Authorization Service

Apache License Build Status

The Authorization service provides basic authorization for all other datawave microservices. Authorization is a single endpoint that returns a signed JSON Web Token (JWT) that represents a list of DatawaveUser objects. Authorization may be performed by a trusted entity (i.e., a server) on behalf of another user or chain of servers leading to a user.

The Authorization service caches authorized users and also provides an administrative rest API to query and manage the cache.

When the fields 'email' and 'login' were added to DatawaveUser, we created V2 of the authorization and oauth API methods to ensure that microservices using the pre-change authorization-api could still deserialize the JSON or JWT serialized DatawaveUser when they call the V1 methods.

Authorization API V1

https://host:port/authorization/v1/

MethodOperationDescriptionRequest Body
GETauthorizeAuthorizes the calling userN/A
GETwhoamiReturns details about the calling userN/A

Authorization API V2

https://host:port/authorization/v2/

MethodOperationDescriptionRequest Body
GETauthorizeAuthorizes the calling userN/A
GETwhoamiReturns details about the calling userN/A

OAuth API V2

https://host:port/authorization/v2/oauth/

MethodOperationDescriptionRequest Body
GETauthorizeFor registered client_id and authorized user, return a short-lived code that can be used by the client to retrieve a user's JWTN/A
POSTtokenUsing either a code from 'authorize' or a refresh_token, a registered can fetch the corresponding user's JWTN/A
GETuserReturns details about primary current (by token or PKI) userN/A
GETusersReturns details about all current (by token or PKI) proxied usersN/A

Admin API

Users must possess the Administrator role to access any of the admin methods.

MethodOperationDescriptionRequest Body
DELETEadmin/evictAllDeletes all users from the cacheN/A
DELETEadmin/evictUserDeletes the named user from the cacheN/A
DELETEadmin/evictUsersMatchingDeletes users with names containing the supplied string from the authorization cacheN/A
GETadmin/listUsersShows all users in the cacheN/A
GETadmin/listUserRetrieves the named user from the cacheN/A
GETadmin/listUsersMatchingRetrieves users with names containing the supplied string from the authorization cacheN/A

Getting Started

  1. First, refer to services/README for launching the config service.

  2. Launch this service as follows, with the mock profile to leverage test PKI materials and associated user configuration (see authorization-mock.yml).

    java -jar service/target/authorization-service*-exec.jar --spring.profiles.active=dev,mock
    
  3. Ensure that the testUser.p12 (password: ChangeIt) cert is imported into your browser, and then visit any of the following:

    See sample_configuration/authorization-dev.yml and configure as desired

hacktoberfest

NationalSecurityAgency/datawave-authorization-service

Java

8

218 commits

updated Feb 20, 2025

See the code

README

Authorization Service

Apache License Build Status

The Authorization service provides basic authorization for all other datawave microservices. Authorization is a single endpoint that returns a signed JSON Web Token (JWT) that represents a list of DatawaveUser objects. Authorization may be performed by a trusted entity (i.e., a server) on behalf of another user or chain of servers leading to a user.

The Authorization service caches authorized users and also provides an administrative rest API to query and manage the cache.

When the fields 'email' and 'login' were added to DatawaveUser, we created V2 of the authorization and oauth API methods to ensure that microservices using the pre-change authorization-api could still deserialize the JSON or JWT serialized DatawaveUser when they call the V1 methods.

Authorization API V1

https://host:port/authorization/v1/

MethodOperationDescriptionRequest Body
GETauthorizeAuthorizes the calling userN/A
GETwhoamiReturns details about the calling userN/A

Authorization API V2

https://host:port/authorization/v2/

MethodOperationDescriptionRequest Body
GETauthorizeAuthorizes the calling userN/A
GETwhoamiReturns details about the calling userN/A

OAuth API V2

https://host:port/authorization/v2/oauth/

MethodOperationDescriptionRequest Body
GETauthorizeFor registered client_id and authorized user, return a short-lived code that can be used by the client to retrieve a user's JWTN/A
POSTtokenUsing either a code from 'authorize' or a refresh_token, a registered can fetch the corresponding user's JWTN/A
GETuserReturns details about primary current (by token or PKI) userN/A
GETusersReturns details about all current (by token or PKI) proxied usersN/A

Admin API

Users must possess the Administrator role to access any of the admin methods.

MethodOperationDescriptionRequest Body
DELETEadmin/evictAllDeletes all users from the cacheN/A
DELETEadmin/evictUserDeletes the named user from the cacheN/A
DELETEadmin/evictUsersMatchingDeletes users with names containing the supplied string from the authorization cacheN/A
GETadmin/listUsersShows all users in the cacheN/A
GETadmin/listUserRetrieves the named user from the cacheN/A
GETadmin/listUsersMatchingRetrieves users with names containing the supplied string from the authorization cacheN/A

Getting Started

  1. First, refer to services/README for launching the config service.

  2. Launch this service as follows, with the mock profile to leverage test PKI materials and associated user configuration (see authorization-mock.yml).

    java -jar service/target/authorization-service*-exec.jar --spring.profiles.active=dev,mock
    
  3. Ensure that the testUser.p12 (password: ChangeIt) cert is imported into your browser, and then visit any of the following:

    See sample_configuration/authorization-dev.yml and configure as desired

hacktoberfest