-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rewrite to own user db Token endpoint replaced with more generic user resource which also allows deleting oauth2proxy users (because the original user deletion API has their 2 internal sources hardcoded and rejects all others). The realm also handles username + password for programmatic access now. It makes use of an hashed api token column in the new dedicated user db. IDP group to nexus role mapping works without the name prefix. There's a dedicated db that collects the groups of all users logging in. Then they can be used with the original external role mapping mechanism of nexus. * Let's not log credentials * Set the random api token of new users before persisting
- Loading branch information
1 parent
177e7d2
commit 8ecf60e
Showing
24 changed files
with
1,961 additions
and
257 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,30 +4,26 @@ This plugin has been developed to facilitate the integration of Nexus with any i | |
|
||
Rather than executing its own OIDC (OpenID Connect) authentication flow, this plugin leverages OAuth2 Proxy to undertake the authentication process, relying on it to provide the necessary information through headers. | ||
|
||
Furthermore, acknowledging the importance of non-interactive programmatic access within the Nexus environment, this plugin incorporates an API token feature. This feature ingeniously utilizes the password field of a local user object for storage purposes (acknowledged as a makeshift solution, with potential revisions anticipated). While users are unable to modify their passwords without prior knowledge of the existing one, the plugin introduces an additional endpoint. This endpoint enables authenticated users to reset their password to a system-generated one via the Nexus UI, with the caveat that this token is displayed solely once and is subject to reset with each access of the user menu item. | ||
Furthermore, acknowledging the importance of non-interactive programmatic access within the Nexus environment, this plugin incorporates an API token feature. The plugin introduces an additional endpoint that allows authenticated users to reset their own API token to a system-generated one via the Nexus UI, with the caveat that this token is displayed solely once and is subject to reset with each access of this user menu item. | ||
|
||
## ⚠️ State of Development & Disclaimer | ||
## ⚠️ Disclaimer | ||
|
||
The plugin currently encompasses the essential components required for operational functionality and is presently undergoing a testing phase. It is important to highlight that this plugin is provided on an 'as-is' basis, without any form of express or implied warranty. Under no circumstances shall the authors be held accountable for any damages or liabilities arising from the utilization of this plugin. Users are advised to proceed at their own risk. | ||
It is important to highlight that this plugin is provided on an 'as-is' basis, without any form of express or implied warranty. Under no circumstances shall the authors be held accountable for any damages or liabilities arising from the utilization of this plugin. Users are advised to proceed at their own risk. | ||
|
||
## Features | ||
|
||
* makes use of several headers sent by OAuth2 proxy (depending on its configuration) | ||
* see constants in [OAuth2ProxyHeaderAuthTokenFactory](src/main/java/com/github/tumbl3w33d/OAuth2ProxyHeaderAuthTokenFactory.java) | ||
* creates an AuthenticationToken used by Nexus | ||
* creates a user in the local Nexus database if none with the given id (`preferred_username`) exists | ||
* creates a user in a dedicated database (i.e., not the 'local db' of Nexus) if none with the given id (`preferred_username`) exists | ||
* anyone authenticated with your identity provider can access Nexus | ||
* you would control access by granting necessary scopes accessing OAuth2 Proxy only to eligible user groups | ||
* user creation currently has a rather simplistic strategy to extract `<firstname>.<lastname>` from `preferred_username` | ||
* reuses existing user object from another existing realm (e.g. LDAP) | ||
* ⚠️ this might not be appropriate for your setup, do your own testing or make sure there is no other realm active that holds user objects | ||
* group/scope to role sync | ||
* if you configure OAuth2 Proxy with the well-known `groups` claim, it will retrieve that information from the identity provider | ||
* the groups received in the related header will be mapped to roles that you need to (manually) create in Nexus | ||
* be aware that, in order to distinguish between role mappings connected with this realm and others, all groups will be prefixed with `idp-`, so name your roles accordingly and the user will magically receive/lose them on every login | ||
* Example: idp group `[email protected]` will map to `[email protected]` role in Nexus | ||
* the groups received in the related header will be stored in a database and become available for the 'external role mapping' functionality | ||
* automatic expiry of API tokens | ||
* there is a configurable task that lets API tokens expire, so another interactive login by the user is necessary to renew it | ||
* there is a configurable task that lets API tokens expire, so another login by the user is necessary to renew it | ||
* as long as the user keeps showing up regularly, their token will not expire | ||
|
||
**Note**: After authenticating with this realm, the logout button is non-operative, which is a common limitation with header-based authentication methods. To force a logout, you need to logout from your identity provider and/or delete the OAuth2 Proxy cookie if you must logout for some reason. | ||
|
@@ -36,7 +32,7 @@ The plugin currently encompasses the essential components required for operation | |
|
||
You typically put an OAuth2 Proxy in front of your application and make sure that related `X-Forwarded-` headers do not reach the application other than those originating from the OAuth2 Proxy. | ||
|
||
For non-interactive programmatic access you circumvent the OAuth2 Proxy and go straight to the Nexus application. To achieve that, you could check for the presence of an `Authorization: Basic` header earlier in the chain of proxies. In that case the required credentials are the user's id and the generated API token. It is handled by the default implementation of Nexus and not touched by this plugin. | ||
For non-interactive programmatic access you circumvent the OAuth2 Proxy and go straight to the Nexus application. To achieve that, you could check for the presence of an `Authorization: Basic` header earlier in the chain of proxies. In that case the required credentials are the user's id and the generated API token. | ||
|
||
## Example with HAProxy as entrypoint | ||
|
||
|
@@ -51,7 +47,10 @@ frontend you-name-it | |
# circumvent oauth2 proxy for programmatic access | ||
acl is_basic_auth hdr_beg(Authorization) -i basic | ||
use_backend nexus if is_basic_auth | ||
# clients often send a HEAD request without Authorization header first | ||
# and this must reach nexus directly, else the OAuth2 dance starts | ||
acl is_head method HEAD | ||
use_backend nexus if is_basic_auth OR is_head | ||
default_backend oauth2-proxy | ||
|
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
78 changes: 0 additions & 78 deletions
78
src/main/java/com/github/tumbl3w33d/OAuth2ProxyApiTokenEndpoint.java
This file was deleted.
Oops, something went wrong.
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.