Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
815e8a9
Add OIDC authentication support to backend and frontend
Brramble Oct 28, 2025
35b950e
Fix auth page issue
Brramble Oct 28, 2025
492399c
Attempt at fixing API settings
Brramble Oct 28, 2025
9c685a8
Fix boolean
Brramble Oct 28, 2025
9ccab18
Various fixes
Brramble Oct 28, 2025
bf482b6
Relax OIDC cookie settings and add debug prints
Brramble Oct 28, 2025
2dbd5ef
Add OIDC user info display to settings page
Brramble Oct 28, 2025
7916c49
Add clear instructions in the UI
Brramble Oct 28, 2025
6b24007
Update the CSS
Brramble Oct 28, 2025
fb1ed24
Better instructions in settings page
Brramble Oct 28, 2025
c9236e0
Make CSS look better
Brramble Oct 28, 2025
af191e8
Fix CSS colours
Brramble Oct 28, 2025
17858ab
Update settings-page.scss
Brramble Oct 28, 2025
08445cf
Update authlub py package to latest
Brramble Oct 28, 2025
d13ada2
Add OIDC authentication support to backend and frontend
Brramble Oct 28, 2025
97affed
Fix auth page issue
Brramble Oct 28, 2025
dd037d3
Attempt at fixing API settings
Brramble Oct 28, 2025
c1ab9c3
Fix boolean
Brramble Oct 28, 2025
cba6950
Various fixes
Brramble Oct 28, 2025
f58c761
Relax OIDC cookie settings and add debug prints
Brramble Oct 28, 2025
4d4ffad
Add OIDC user info display to settings page
Brramble Oct 28, 2025
82f5502
Add clear instructions in the UI
Brramble Oct 28, 2025
b6ac209
Update the CSS
Brramble Oct 28, 2025
9071cae
Better instructions in settings page
Brramble Oct 28, 2025
821c7e7
Make CSS look better
Brramble Oct 28, 2025
b115414
Fix CSS colours
Brramble Oct 28, 2025
51fb470
Update settings-page.scss
Brramble Oct 28, 2025
5660bf9
Update authlub py package to latest
Brramble Oct 28, 2025
4f3e530
Create merge_heads_agent_oidc.py
Brramble Nov 1, 2025
2535709
Uniform structure of backend
Brramble Nov 1, 2025
292747d
Delete merge_heads_agent_oidc.py
Brramble Nov 1, 2025
4589413
Move OIDC config to env vars and remove UI settings
Brramble Nov 3, 2025
51c8a9e
Merge branch 'main' of https://github.com/Brramble/tugtainer
Brramble Nov 3, 2025
3a98f52
Update .env.example
Brramble Nov 3, 2025
cc7bec8
Merge branch 'Quenary:main' into main
Brramble Nov 3, 2025
8a5b084
Restore auth api cookie settings
Brramble Nov 3, 2025
9ef2bc3
Merge branch 'main' of https://github.com/Brramble/tugtainer
Brramble Nov 3, 2025
a82795e
Merge branch 'main' into OIDC-auth
Quenary Nov 5, 2025
31d9e55
refactor: removed unused oidc related code
Quenary Nov 5, 2025
3cb101d
refactor: auth providers
Quenary Nov 5, 2025
63f27c9
refactor: auth api
Quenary Nov 5, 2025
6d8af58
refactor: removed unused code
Quenary Nov 5, 2025
e6a39f4
Merge pull request #1 from Quenary/OIDC-auth
Brramble Nov 7, 2025
85bdcc4
Backend changes for OIDC redirect
Brramble Nov 9, 2025
bd743eb
Add OIDC auto-redirect check to auth page
Brramble Nov 9, 2025
7a0387d
Merge branch 'main' of https://github.com/Brramble/tugtainer
Brramble Nov 9, 2025
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ OIDC_REDIRECT_URI=
# Space-separated scopes
# Default is "openid profile email"
OIDC_SCOPES=
# Automatically redirect to OIDC provider instead of showing login page
# When enabled, users will be immediately redirected to the OIDC provider
# instead of seeing the login screen (only works when password auth is disabled)
# Default is FALSE
OIDC_AUTO_REDIRECT=
#endregion
10 changes: 10 additions & 0 deletions backend/api/auth_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ def is_password_set() -> bool:
return AUTH_PASSWORD_PROVIDER.is_password_set()


@router.get(
path="/oidc_auto_redirect",
description="Check if OIDC auto redirect is enabled",
response_model=bool,
)
async def oidc_auto_redirect() -> bool:
from backend.config import Config
return Config.OIDC_AUTO_REDIRECT


Comment on lines +94 to +103
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think this is the right approach to implement it as separate exclusive method for the OIDC in auth_api.
I think should be in AuthProvider and child classes - something like existing /{provider}/login and /{provider}/callback
For password provider it is always false obviously, but other providers may be added in the future.

@router.get(
path="/{provider}/login", description="Login with provider"
)
Expand Down
2 changes: 2 additions & 0 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Config:
OIDC_CLIENT_SECRET: ClassVar[str]
OIDC_REDIRECT_URI: ClassVar[str]
OIDC_SCOPES: ClassVar[str]
OIDC_AUTO_REDIRECT: ClassVar[bool]

@classmethod
def load(cls):
Expand Down Expand Up @@ -63,6 +64,7 @@ def load(cls):
cls.OIDC_CLIENT_SECRET = os.getenv("OIDC_CLIENT_SECRET", "")
cls.OIDC_REDIRECT_URI = os.getenv("OIDC_REDIRECT_URI", "")
cls.OIDC_SCOPES = os.getenv("OIDC_SCOPES", "openid profile email")
cls.OIDC_AUTO_REDIRECT = os.getenv("OIDC_AUTO_REDIRECT", "false").lower() == "true"


Config.load()
8 changes: 8 additions & 0 deletions frontend/src/app/entities/auth/auth-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ export class AuthApiService extends BaseApiService<'/auth'> {
isPasswordSet(): Observable<boolean> {
return this.httpClient.get<boolean>(`${this.basePath}/is_password_set`);
}

/**
* Check if OIDC auto redirect is enabled
* @returns
*/
isOidcAutoRedirectEnabled(): Observable<boolean> {
return this.httpClient.get<boolean>(`${this.basePath}/oidc_auto_redirect`);
}
Comment on lines +61 to +67
Copy link
Owner

Choose a reason for hiding this comment

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

Same here, it's need to be universal request for provider

}
33 changes: 33 additions & 0 deletions frontend/src/app/features/auth-page/auth-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export class AuthPage {
private readonly router = inject(Router);
private readonly toastService = inject(ToastService);

constructor() {
// Check for OIDC auto-redirect when component initializes
this.checkOidcAutoRedirect();
}

public readonly isLoading = signal<boolean>(false);
public readonly isPasswordSet = resource({
defaultValue: false,
Expand Down Expand Up @@ -65,6 +70,20 @@ export class AuthPage {
),
});

public readonly isOidcAutoRedirectEnabled = resource({
defaultValue: false,
loader: () =>
firstValueFrom(
this.authApiService.isOidcAutoRedirectEnabled().pipe(
retry(1),
catchError((error) => {
this.toastService.error(error);
return throwError(() => error);
}),
),
),
});
Comment on lines +73 to +85
Copy link
Owner

Choose a reason for hiding this comment

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

Using the resource pattern isn't justified sirce this value is not used in the template.
It is worth simply subscribe to authApiService method in the constructor.


onSubmitNewPassword($event: ISetPasswordBody): void {
this.isLoading.set(true);
this.authApiService
Expand Down Expand Up @@ -99,4 +118,18 @@ export class AuthPage {
onOidcLogin(): void {
this.authApiService.initiateLogin('oidc');
}

private checkOidcAutoRedirect(): void {
// Wait for resources to load, then check if auto-redirect should happen
setTimeout(() => {
const oidcEnabled = this.isOidcEnabled.value();
const passwordEnabled = this.isPasswordEnabled.value();
const autoRedirectEnabled = this.isOidcAutoRedirectEnabled.value();

// Auto-redirect if OIDC auto-redirect is enabled, OIDC is enabled, and password auth is disabled
if (autoRedirectEnabled && oidcEnabled && !passwordEnabled) {
this.authApiService.initiateLogin('oidc');
}
}, 100);
}
}