Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support OIDC authentication #184

Open
wants to merge 73 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
8d64b6f
feat: support OIDC authentication
michaelhthomas Jul 11, 2022
158feb4
refactor: decouple Plex OAuth login from primary login components
michaelhthomas Jul 11, 2022
312b3df
chore: update & fix translations
michaelhthomas Jul 11, 2022
c0e8934
Merge branch 'develop' into oidc-login
michaelhthomas Jul 15, 2022
377d765
fix: make jellyfin login properly communicate with setup
michaelhthomas Jul 23, 2022
2989aba
Merge remote-tracking branch 'upstream/develop' into oidc-login
michaelhthomas Sep 18, 2022
2e7c0be
fix: do not require a server restart to update OIDC issuer
michaelhthomas Sep 25, 2022
88dfb99
fix: ignore trailing slashes in oidc issuer url
michaelhthomas Sep 25, 2022
88ac5af
fix: don't get stuck in an infinite loop if oidc server validation fails
michaelhthomas Sep 25, 2022
1c8829a
fix: do not remove trailing slash from OIDC issuer URL as some provid…
michaelhthomas Oct 26, 2022
617653c
fix: use OIDC id_token to validate user
michaelhthomas Oct 30, 2022
83876e0
perf: cache oidc provider endpoint configuration
michaelhthomas Oct 30, 2022
70c6eaf
fix: restore rounded corners & fix styling bugs
michaelhthomas Nov 14, 2022
32c8b72
fix: ensure correct login page sections are visible
michaelhthomas Nov 14, 2022
67b0c73
fix: separate option for enabling/disabling media server login
michaelhthomas Nov 16, 2022
492aaa4
chore: extract translations
michaelhthomas Nov 18, 2022
3f428e2
wip: merge upstream
michaelhthomas Nov 20, 2022
032f162
Merge remote-tracking branch 'upstream/develop' into oidc-login-upstream
michaelhthomas Nov 20, 2022
90b6285
fix: improve validation for login methods settings
michaelhthomas Nov 29, 2022
795f1fc
chore: remove unnecessary deps
michaelhthomas Nov 29, 2022
8e72c6c
fix: remove OIDC server information from public settings interface
michaelhthomas Nov 29, 2022
77dd853
fix: clean up OIDC login component
michaelhthomas Nov 29, 2022
c273a86
chore: extract translations
michaelhthomas Nov 29, 2022
37ac6b6
Merge branch 'upstream/develop' into oidc-login
Fallenbagel Dec 3, 2022
6461e93
chore: update documentation
michaelhthomas Dec 7, 2022
4c4168c
fix: allow unknown query parameters on oidc callback route
michaelhthomas Dec 13, 2022
1a36f9a
fix: make oidc issuer domain validation less strict
michaelhthomas Dec 13, 2022
d0bf2ec
fix: continue showing loading spinner while redirecting to home page
michaelhthomas Dec 13, 2022
48041f8
feat: merge claims from userinfo response, return json responses from…
michaelhthomas Dec 13, 2022
be7efa3
feat: add oidc callback page and proper error handling
michaelhthomas Dec 13, 2022
a9d2532
fix: accept OIDC audience claim as an array
michaelhthomas Dec 14, 2022
0036d35
feat: allow matching OIDC users to plex/emby/jellyfin by username
michaelhthomas Dec 24, 2022
7ea15dd
chore: extract translations
michaelhthomas Dec 24, 2022
1b9e3a7
Merge remote-tracking branch 'upstream/develop' into oidc-login
michaelhthomas Dec 25, 2022
ea1a59e
Merge remote-tracking branch 'upstream/develop' into oidc-login
michaelhthomas Jan 28, 2023
20983ff
fix: support logging in without popup window
michaelhthomas Feb 21, 2023
e03cb1f
chore: revert translations, add OIDC ones
michaelhthomas Feb 21, 2023
df44afe
Merge remote-tracking branch 'upstream/develop' into oidc-login
michaelhthomas Mar 1, 2023
21cb70f
fix: use preferred_username for new user creation
michaelhthomas Apr 4, 2023
e6d6578
Merge remote-tracking branch 'upstream/develop' into oidc-login
michaelhthomas Jun 11, 2023
c46f0b4
Merge remote-tracking branch 'origin/develop' into pr-184
Fallenbagel Aug 11, 2023
be008cc
Merge branch 'develop' into oidc-login
Fallenbagel Nov 7, 2023
2cf0ed9
feat(Modal): support configuring button type attribute
michaelhthomas Aug 13, 2023
8ac5354
feat: move oidc settings to modal
michaelhthomas Aug 13, 2023
c8abea0
chore(settings): remove extraneous change
michaelhthomas Aug 13, 2023
b9edaf7
fix(auth.ts): improve error handling
michaelhthomas Aug 21, 2023
80f3b19
feat(server): move oidc settings to object, add required claims and s…
michaelhthomas Oct 2, 2023
6ab00e3
feat(client): update settings to support new config schema
michaelhthomas Oct 2, 2023
847d0e2
fix(OidcSettings): simplify settings modal and improve behavior
michaelhthomas Oct 2, 2023
324e76e
fix(User): allow FindOperator queries for email
michaelhthomas Oct 2, 2023
729acb5
fix: update public settings and usages
michaelhthomas Oct 2, 2023
897dbda
fix(auth): modify error message
michaelhthomas Oct 2, 2023
06ab0d4
chore(callback): fix lint error
michaelhthomas Oct 2, 2023
5108699
feat: display new settings in advanced section of modal
michaelhthomas Dec 9, 2023
dc8251f
style: clean up auth routes & types
michaelhthomas Dec 9, 2023
d89ce70
fix(OidcModal): properly rotate accordion dropdown
michaelhthomas Dec 9, 2023
863d537
feat(oidc): add automatic login option
michaelhthomas Dec 9, 2023
54bfd4f
Merge remote-tracking branch 'upstream/develop' into oidc-login
michaelhthomas Dec 9, 2023
b30803a
chore: update API documentation
michaelhthomas Dec 9, 2023
9706853
chore(api-spec): remove extraneous changes
michaelhthomas Dec 9, 2023
6b7dc5c
style: move oidc types into interfaces file
michaelhthomas Dec 9, 2023
6ade3e4
fix(client): add automatic login to default settings
michaelhthomas Dec 9, 2023
d3e477d
fix: properly validate custom user identifiers and required claims
michaelhthomas Dec 10, 2023
6b9c774
fix(callback): show correct error message when OIDC errors occur
michaelhthomas Dec 10, 2023
ddde1d9
fix: don't assume the email claim is present for user registration
michaelhthomas Dec 10, 2023
a911f95
fix(OidcModal): tweak advanced settings collapse ui
michaelhthomas Dec 10, 2023
f9f1a39
chore: update settings documentation
michaelhthomas Dec 10, 2023
f37c416
fix: improve validation of issuer url
michaelhthomas Jan 7, 2024
f1d9ffa
Merge remote-tracking branch 'upstream/develop' into oidc-login
michaelhthomas Jan 7, 2024
6567236
Merge branch 'develop' into oidc-login
Fallenbagel Feb 23, 2024
def0d32
Merge branch 'develop' into oidc-login
Fallenbagel Feb 23, 2024
7867509
fix(OidcModal): avoid using URL.canParse
michaelhthomas Mar 26, 2024
2967878
Merge remote-tracking branch 'origin/develop' into oidc-login
Fallenbagel May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/extending-overseerr/reverse-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ location ^~ /overseerr {
sub_filter '\/_next' '\/$app\/_next';
sub_filter '/_next' '/$app/_next';
sub_filter '/api/v1' '/$app/api/v1';
sub_filter '/login/plex/loading' '/$app/login/plex/loading';
sub_filter '/login/popup/loading' '/$app/login/popup/loading';
sub_filter '/images/' '/$app/images/';
sub_filter '/android-' '/$app/android-';
sub_filter '/apple-' '/$app/apple-';
Expand Down
62 changes: 62 additions & 0 deletions docs/using-overseerr/settings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,68 @@ When disabled, Plex OAuth becomes the only sign-in option, and any "local users"

This setting is **enabled** by default.

### Enable Media Server Sign-In

When enabled, users will be able to sign in on the login screen using their Plex / Jellyfin accounts.

When disabled, local sign-in will be the only option.

This setting is **enabled** by default.

### Enable OIDC Sign-In

When enabled, allows users to sign in to local accounts using an OIDC identity provider, which requires additional configuration.

For this setting to function properly, the OIDC Issuer URL, Provider Name, Client ID, and Client Secret must all be properly set.

This setting is **disabled** by default.

### OIDC Settings

#### Issuer URL

Sets the base URL of the identity provider's OpenID Connect endpoint. A valid URL for this setting should have a discovery endpoint at `/.well-known/openid-configuration` as outlined in the [OpenID Connect Discovery specification](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig).

#### Provider Name

Sets the name that should be shown for the OIDC login option on the login screen.

For example, setting the Provider Name option to "My Incredible Login Page" would make a button with the text "Sign in with My Incredible Login Page" appear on the login page.

#### Client ID

Sets the client ID Jellyseerr should use when communicating with the configured identity provider.

#### Client Secret

Sets the client secret Jellyseerr should use when communicating with the configured identity provider.

#### Scopes

Sets the scopes that should be requested from the identity provider when logging in, as described in the [OpenID Connect specification](https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims). This is an advanced setting, and the default value (`email openid profile`) should be sufficient for most configurations.

#### Identification Claims

Sets the string-typed claims that should be used to identify a user. These claims are matched to the user's unique identifier (email). This is an advanced setting, and the default value (`email`) should be sufficient for most configurations.

#### Required Claims

Sets the boolean-typed claims that should be required for a user to successfully log in. This is an advanced setting, and the default value (`email_verified`) should be sufficient for most configurations. If requiring a verified email address is not desired, it is possible to leave this field blank.

#### Allow Plex / Jellyfin Usernames

When enabled, a user's identification claims are matched not only against their email, but against their Plex / Jellyfin username. This is an advanced setting, and enabling it will likely result in reduced security due to the ease of changing / spoofing usernames.

This setting may be helpful, however, for scenarios when the OpenID connect provider and Plex / Jellyfin's usernames are equivalent for all users. It may be helpful to add `preferred_username` or another of the [standard OpenID Connect claims](https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims) to the [Identification Claims](#identification-claims) setting to enable matching Plex / Jellyfin usernames to the usernames obtained from the identity provider.

This setting is **disabled** by default.

#### Automatic Login

When enabled, OpenID Connect authentication will replace the built-in authentication mechanism. The login page will automatically redirect to the OpenID Connect identity provider, and logging out will trigger an OpenID Connect logout flow. This setting may only be enabled if OIDC Sign-In is the only enabled authentication mechanism.

This setting is **disabled** by default.

### Enable New Plex Sign-In

When enabled, users with access to your Plex server will be able to sign in to Overseerr even if they have not yet been imported. Users will be automatically assigned the permissions configured in the [Default Permissions](#default-permissions) setting upon first sign-in.
Expand Down
111 changes: 111 additions & 0 deletions overseerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,36 @@ components:
type: string
originalLanguage:
type: string
OidcSettings:
type: object
properties:
providerName:
type: string
example: Keycloak
providerUrl:
type: string
example: https://auth.example.com
clientId:
type: string
example: your-client-id
clientSecret:
type: string
example: your-client-secret
userIdentifier:
type: string
example: email
requiredClaims:
type: string
example: email_verified
scopes:
type: string
example: id email
matchJellyfinUsername:
type: boolean
example: false
automaticLogin:
type: boolean
example: false
MainSettings:
type: object
properties:
Expand Down Expand Up @@ -162,6 +192,14 @@ components:
localLogin:
type: boolean
example: true
mediaServerLogin:
type: boolean
example: true
oidcLogin:
type: boolean
example: true
oidc:
$ref: '#/components/schemas/OidcSettings'
mediaServerType:
type: number
example: 1
Expand Down Expand Up @@ -3699,6 +3737,79 @@ paths:
type: string
required:
- password
/auth/oidc-login:
get:
security: []
summary: Redirect to the OpenID Connect provider
description: Constructs the redirect URL to the OpenID Connect provider, and redirects the user to it.
tags:
- auth
responses:
'302':
description: Redirect to the authentication url for the OpenID Connect provider
headers:
Location:
schema:
type: string
example: https://example.com/auth/oidc/callback?response_type=code&client_id=client_id&redirect_uri=https%3A%2F%2Fexample.com%2Fauth%2Foidc%2Fcallback&scope=openid%20email&state=state
Set-Cookie:
schema:
type: string
example: 'oidc-state=123456789; HttpOnly; max-age=60000; Secure'
/auth/oidc-callback:
get:
security: []
summary: The callback endpoint for the OpenID Connect provider redirect
description: Takes the `code` and `state` parameters from the OpenID Connect provider, and exchanges them for a token.
x-allow-unknown-query-parameters: true
parameters:
- in: query
name: code
required: true
schema:
type: string
example: '123456789'
- in: query
name: state
required: true
schema:
type: string
example: '123456789'
- in: cookie
name: oidc-state
required: true
schema:
type: string
example: '123456789'
tags:
- auth
responses:
'302':
description: A redirect to the home page if successful or back to the login page if not
headers:
Location:
schema:
type: string
example: /
Set-Cookie:
schema:
type: string
example: 'oidc-state=deleted; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT'
/auth/oidc-logout:
get:
security: []
summary: Redirect to the OpenID Connect provider logout page
description: Determines the logout redirect URL for to the OpenID Connect provider, and redirects the user to it.
tags:
- auth
responses:
'302':
description: Redirect to the logout url for the OpenID Connect provider
headers:
Location:
schema:
type: string
example: https://example.com/auth/oidc/invalidate_session
/user:
get:
summary: Get all users
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"formik": "2.2.9",
"gravatar-url": "3.1.0",
"intl": "1.2.5",
"jwt-decode": "^3.1.2",
"lodash": "4.17.21",
"next": "12.3.4",
"node-cache": "5.1.2",
Expand Down
8 changes: 7 additions & 1 deletion server/entity/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
PrimaryGeneratedColumn,
RelationCount,
UpdateDateColumn,
type FindOperator,
} from 'typeorm';
import Issue from './Issue';
import { MediaRequest } from './MediaRequest';
Expand Down Expand Up @@ -51,7 +52,12 @@ export class User {
unique: true,
transformer: {
from: (value: string): string => (value ?? '').toLowerCase(),
to: (value: string): string => (value ?? '').toLowerCase(),
to: (
value: string | FindOperator<string>
): string | FindOperator<string> => {
if (typeof value === 'string') return (value ?? '').toLowerCase();
return value;
},
},
})
public email: string;
Expand Down
Loading
Loading