Skip to content

feat: support for forwardAuth - #580

Closed
Janhouse wants to merge 2 commits into
seerr-team:developfrom
Janhouse:forward-auth
Closed

feat: support for forwardAuth#580
Janhouse wants to merge 2 commits into
seerr-team:developfrom
Janhouse:forward-auth

Conversation

@Janhouse

@Janhouse Janhouse commented Nov 28, 2023

Copy link
Copy Markdown

Description

Add support for forwardAuth available with nginx, caddy, traefik, etc. which allows use of SSO without exposing any jellyseerr services to unauthenticated users.

Inspired by similar PR in overseer but slightly simplified, requiring existing user to authenticate.

To-Dos

  • Successful build yarn build

Fixes

@Janhouse
Janhouse requested a review from gauthier-th as a code owner October 5, 2024 12:39
@github-actions github-actions Bot added the merge conflict Cannot merge due to merge conflicts label Oct 16, 2024
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@github-actions github-actions Bot removed the merge conflict Cannot merge due to merge conflicts label Oct 17, 2024

@gauthier-th gauthier-th left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a bit of documentation for this?


This works by passing the authenticated user e-mail in `X-Forwarded-User` header by the auth server, therefore enabling single-sign-on (SSO) login.

> The user has to exist, it will not be created automatically.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to use a warning instead of a citation.

Suggested change
> The user has to exist, it will not be created automatically.
:::warning
The user has to exist, it will not be created automatically.
:::

Comment thread server/middleware/auth.ts
Comment on lines +30 to +36
if (user) {
req.user = user;
}

req.locale = user?.settings?.locale
? user.settings.locale
: settings.main.locale;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary, it's a duplicate from below.

Comment thread overseerr-api.yml
Comment on lines +190 to +192
enableForwardAuth:
type: boolean
example: true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wrote the setting here, but it is not available anywhere.

You should add this as a general setting, by adding a new properties in the MainSettings type in server/lib/settings.ts and adding a new input in the settings page in src/components/Settings/SettingsMain/index.tsx. You should also check that this setting is enabled before allowing login with forwardAuth.

Or did you intend to not make a setting and set it enabled by default?

Comment thread overseerr-api.yml
security:
- cookieAuth: []
- apiKey: []
- forwardAuth: []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import type { GetServerSidePropsContext, PreviewData } from 'next/types';
import type { ParsedUrlQuery } from 'querystring';

export const getRequestHeaders = (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this function be called something like getAuthHeaders instead of getRequestHeaders?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wdyt about renaming this file to something like serverSidePropsHelpers?

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@github-actions github-actions Bot added the merge conflict Cannot merge due to merge conflicts label Dec 29, 2024
@fallenbagel fallenbagel mentioned this pull request Jan 4, 2025
1 task
@hiasr

hiasr commented Jan 4, 2025

Copy link
Copy Markdown

LMK if any help is needed here, would love to get this through!

@Janhouse

Copy link
Copy Markdown
Author

@hiasr @gauthier-th, feel free to make the necessary changes. I made them when I had some free time but that is currently not the case.

@gauthier-th

Copy link
Copy Markdown
Member

Closed in favor of #1341

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Cannot merge due to merge conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Forward Auth

3 participants