Add OIDC SSO login and account linking - #2077
Conversation
|
Frontend code: koush/manage.scrypted.app#17 |
Adds PKCE (S256 code challenge) to the OIDC authorization flow and removes the usernameClaim and allowUnmappedUsers settings in favor of simpler defaults.
…Type to client - Fix post-login redirect resolving relative to /login/oidc/callback - Make all OIDC settings readonly in the UI (env var only config) - Add ScryptedSettings interface to OIDCCore so it appears in Settings page - Expose authType in checkScryptedClientLogin response for UI login flow
- Always run syncUsers on a 60s interval so OIDC-created users get
discovered as plugin devices without requiring a restart
- Guard getDeviceByName('@scrypted/webrtc') against undefined when
webrtc plugin is not installed
- Store oidcSubject as iss:sub per OIDC spec (Authelia uses UUID sub) - Remove username-based account merge fallback to prevent account takeover - Throw on username collision instead of silently merging into existing account - Add secure flag to oidc_state cookie - Sanitize preferred_username/email claims before use as user _id - Add /login/oidc/link endpoint for linking existing accounts to OIDC - Validate session matches linkUsername at callback to prevent account hijack - Add linkOidcSubject/unlinkOidcSubject to UsersService - Expose oidcLinked and unlink button in user settings
|
I think a lot of this can be done already via magic headers accompanied with admin keys, ie a proxy uses admin auth, specifies a user, which is automatically created/logged in. I haven't looked at it in some time, but its a general purpose external auth mechanism that is managed by the proxy layer, and doesn't require server plumbing. |
I get that and could try to look into it in the future, but what's wrong with implementing the full flow in the server? Most apps nowadays support full OIDC and it has become a pretty common method for managing users in one place. |
Not really, at least not in any safe way, I've tried doing that a while back, and it introduces a lot more complexity than just supporting a proper standard. |
|
Gotcha, this can definitely be done as a plugin. It's how the cloud and core plugin work. They can create users as needed using the Scrypted APIs. Run your own frontend server and implement whatever endpoints you need and proxy the rest to the backend. Though I am looking only at this change so far, I'll need to review the ui frontend too. |
Adds OpenID Connect (OIDC) authentication to Scrypted, enabling SSO via providers like Authelia. This is a server-side implementation (not a plugin) since it needs to set signed cookies and call UsersService directly.
Features
from user settings
via the UI
Configuration
Security
Code was generated with Claude but thoroughly tested locally. Please review :)