-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature / Basic authentication provider (#200)
* Add gRPC error code translation for UNAVAILABLE and PERMISSION_DENIED * Add JWT dependency * JWT encode / decode classes * HTTP/1 auth handler with pluggable auth provider interface * Basic auth provider * Guest auth provider * Remove JWT dependency in gateway (it is wrapped in common lib) * Add a test case for JWT encoding / decoding * Fix quoting in JWT encoding / decoding * Auth interceptor to perform authentication for gRPC service (no authorization yet) * Add auth interceptor to the three main services, and log user info in gRPC server wrap * Add a stub for the new auth tool * Utility functions for working with keys and key stores * Make JksSecretLoader use the new CryptoUtils functions * Error case tests for crypto helpers * Split JWS logic in to validator (ro) and processor (rw) * Some basic functional tests for JWT processing / validation (i.e. JWT auth) * Finish working on JWT processor + tests * Additions to config loading framework * Add authentication config to the config file structures * Config keys for public / private root auth secrets * Additions to config loading framework * Add an auth interceptor for gPRC, using the JwtValidator to test authentication * Apply auth to the core platform services * A client auth provider, for supplying auth tokens into gRPC calls from clients * Add auth-tool step to PlatformTest setup code * Make API tests for metadata service work with auth tokens * Fixes to pass auth tokens through from data service to metadata service * Relay owner token in orchestrator * Config updates for integration tests * Config updates for end-to-end tests * Standard handling for plugin config * Make IAuthProvider a registered plugin serice type * Use plugins to set up the auth provider in the gateway * Fix secret key for metadb integration tests * Move auth provider interface into common lib * Move the standard auth plugin into the common library * Switch IAuthProvider to return UserInfo objects * Gateway core auth implementation * Gateway auth update for REST APIs * Dev local config updates * Put user ID / name from authentication into the metadata * Make guest auth provider props camel case * Add default (guest) auth config to sandbox dist config files * Fix root signing key for gateway tests * Set up auth keys in integration jobs for metadb * Stub out implementation of basic auth * Set up auth keys in integration jobs for metadb * Allow a secret key to be passed into the platform test setup * Add password functions to crypto helpers * Auth tool tasks for adding users to local user db * Fix in gateway tests * Handle bearer auth in auth interceptor, report auth errors with an exception * Tidier closing in auth interceptor on auth failures * Translate UNAUTHENTICATED code in rest API response translation * Handle plugin secrets in plugin manager createService * Add containsAttr in crypto helpers * Full impl for basic auth provider * Make config manager give out the user DB * Add secret attrs to secret loaders * Use config manager in plugin manager createService to resolve plugin secrets * Auth tool fixes * Give TRAC users to auth providers that need it in the gateway * Refactored auth setup task name in integration workflow * SnakeYAML vulnerabilities * Initial documentation for the authentication system
- Loading branch information
Martin Traverse
authored
Nov 15, 2022
1 parent
18fc00e
commit a12369a
Showing
71 changed files
with
3,462 additions
and
133 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
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,10 @@ platformInfo: | |
production: false | ||
|
||
|
||
authentication: | ||
jwtIssuer: http://localhost:8080/ | ||
|
||
|
||
instances: | ||
|
||
meta: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
|
||
Authentication | ||
============== | ||
|
||
Authentication in TRAC consists of two main elements: | ||
|
||
* JWT tokens, which are created and validated by the platform and hold information about users | ||
* Authentication providers, which provide the log-on mechanism and are the source of user details | ||
|
||
When a user logs on they are authenticated by an authentication provider, once authentication is successful | ||
their details are retrieved from the provider and coded into a JWT token. The JWT token gives them access to | ||
the platform for a limited period of time, after which they must be re-authenticated with the provider. | ||
|
||
TRAC supports multiple authentication providers and more can be added using the TRAC plugins API. | ||
The JWT mechanism is owned by the platform, and cannot be extended. | ||
|
||
|
||
Root Signing Key | ||
---------------- | ||
|
||
The authentication system requires a root signing key, that is used by the platform to sign | ||
and validate JWT tokens. In order to set up the key you must have secrets configured, in both | ||
the platform and gateway config files. | ||
|
||
You will also need to add an authentication block in both config files, specifying the issuer | ||
and expiry times for JWT tokens. If you know the DNS address that TRAC will be served from you | ||
could use this as the JWT issuer, other options could be the user ID of a service account you | ||
have set up to run TRAC, or a TRAC reserved identifier such as "trac_system". | ||
|
||
.. code-block:: yaml | ||
config: | ||
secret.type: PKCS12 | ||
secret.url: secrets.p12 | ||
authentication: | ||
jwtIssuer: http://localhost:8080/ | ||
jwtExpiry: 7200 | ||
The auth-tool utility can be used to generate the root signing key, it will be written into the | ||
secret store. The available key types are elliptic curve (EC) or RSA. Elliptic curve keys are | ||
considered to give better security with better performance at lower key sizes. For this reason | ||
we recommended EC 256 keys. | ||
|
||
.. tab-set:: | ||
|
||
.. tab-item:: Linux / macOS | ||
:sync: platform_linux | ||
|
||
.. code-block:: shell | ||
cd /opt/trac/current | ||
bin/auth-tool run --task create_root_auth_key EC 256 | ||
.. tab-item:: Windows | ||
:sync: platform_windows | ||
|
||
.. code-block:: batch | ||
cd /d C:\trac\tracdap-sandbox-<version> | ||
bin\auth-tool.bat run --task create_root_auth_key EC 256 | ||
Providers | ||
--------- | ||
|
||
You need to configure one provider in the authentication section of the gateway config file. | ||
|
||
.. note:: | ||
The JWT settings are still needed in the authentication section of the gateway config file, | ||
do not remove them! | ||
|
||
**Guest Provider** | ||
^^^^^^^^^^^^^^^^^^ | ||
|
||
The guest provider logs everyone in as guest, without prompting for credentials. | ||
The user ID and name can be set as properties of the provider. | ||
|
||
.. code-block:: yaml | ||
authentication: | ||
provider: | ||
protocol: guest | ||
properties: | ||
userId: guest | ||
userName: Guest User | ||
**Basic Provider** | ||
^^^^^^^^^^^^^^^^^^ | ||
|
||
The basic provider uses HTTP basic authentication, which typically causes the browser | ||
authentication window to appear when users try to access pages in a browser. | ||
|
||
To use the basic provider, you must configure the TRAC user database. This is set up in the | ||
config section of the gateway config file. The provider must also be set up in the authentication | ||
section with protocol 'basic', it does not require any other properties. | ||
|
||
.. code-block:: yaml | ||
config: | ||
users.type: PKCS12 | ||
users.url: local_users.p12 | ||
users.key: local_users_key | ||
authentication: | ||
provider: | ||
protocol: basic | ||
Before you can use the TRAC user database, you will need to initialize it and add at least one user. | ||
The auth-tool utility will let you do this. The add_user command is interactive and will ask for | ||
details to create a user. | ||
|
||
.. tab-set:: | ||
|
||
.. tab-item:: Linux / macOS | ||
:sync: platform_linux | ||
|
||
.. code-block:: shell | ||
cd /opt/trac/current | ||
bin/auth-tool run --task init_trac_users | ||
bin/auth-tool run --task add_user | ||
bin/auth-tool run --task delete_user <user_id> | ||
.. tab-item:: Windows | ||
:sync: platform_windows | ||
|
||
.. code-block:: batch | ||
cd /d C:\trac\tracdap-sandbox-<version> | ||
bin\auth-tool.bat run --task init_trac_users | ||
bin\auth-tool.bat run --task add_user | ||
bin\auth-tool.bat run --task delete_user <user_id> |
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 |
---|---|---|
|
@@ -15,3 +15,4 @@ Deployment | |
sandbox | ||
platform | ||
metadata_store | ||
authentication |
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.