Skip to content

OAuth2/OIDC support#387

Open
Deleranax wants to merge 2 commits intoddvk:masterfrom
Deleranax:master
Open

OAuth2/OIDC support#387
Deleranax wants to merge 2 commits intoddvk:masterfrom
Deleranax:master

Conversation

@Deleranax
Copy link

This PR adds the support for OAuth2/OIDC log in (and user provisioning). The implementation uses the built-in user system, and only do log in/register with OIDC (it doesn't use the session management mechanisms of OIDC).

This fork was not intended to be merged with upstream, but after seeing that SSO was a requested feature (issue #233), I decided to open this pull request (hoping that it can be useful!).

Work done:

  • Added all required environment variables (RM_OIDC_ISSUER, RM_OIDC_CLIENT_ID, RM_OIDC_CLIENT_SECRET) plus some customisation (RM_OIDC_LABEL to change the log in button label, RM_OIDC_ONLY to disable password auth)
  • Added 3 new API routes (ui/api/oidc/info to query OIDC availability and button label, ui/api/oidc/auth to launch OIDC auth, ui/api/oidc/callback to finish OIDC auth)
  • Added a log out landing page, which is only useful when password auth is disabled (to prevent auto log in). The page just redirect the user to the log in page when password auth is enabled.
  • Updated dependencies (I'm not very skilled with Go dependency management, and it was the only way I found for it to work, don't hesitate to correct me).
  • Added user provisioning (when OPEN_REGISTRATION is true). The new users use a randomly generated password (which is not used when OIDC is enabled).
  • Updated docs with the added features (and description of the env vars).

A working Docker image is hosted on DockerHub (deleranax/rmfakecloud).

- Added OIDC log in (and user provisioning)
- Added config env vars for OIDC
- Added log out page
- Updated dependencies
@rmitchellscott
Copy link
Contributor

Does this assign the admin role based on OIDC group membership?

@Deleranax
Copy link
Author

Does this assign the admin role based on OIDC group membership?

In the current version no. Only the first user receives the admin role and can then assign this role to other users. But I'm willing to work on this feature if you wish.

Scopes: []string{oidc.ScopeOpenID, "profile", "email"},
}

c.String(http.StatusOK, app.oauth2Config.AuthCodeURL("")) // todo: store and verify OAuth2 states

Check failure

Code scanning / CodeQL

Use of constant `state` value in OAuth 2.0 URL High

Using a constant
state string
to create oauth2 URLs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants