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(ui, server): Generic SSO OAuth2 OpenID Connect #188

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fa39410
[WIP] feat(ui, server): Generic SSO OAuth2 OpenID Connect
DelaunayAlex Oct 1, 2024
6988c7c
[WIP] feat(server, ui): Conf SSO OAuth2
DelaunayAlex Oct 3, 2024
8c5d14f
feat(server, ui): SSO OAuth2 with mock oidc-provider, authenticate SS…
DelaunayAlex Oct 10, 2024
0e8ac00
feat(server, ui): SSO OAuth2 with mock oidc-provider, authenticate SS…
DelaunayAlex Oct 10, 2024
b492609
feat(ui, server): Doc local oidc provider
DelaunayAlex Oct 14, 2024
9ffca82
feat(server, ui): Fix PR
DelaunayAlex Oct 20, 2024
e9f42b4
feat(server, ui): Add licence
DelaunayAlex Oct 22, 2024
1fa05b0
feat(ui): Use app initializer
DelaunayAlex Oct 22, 2024
0853d58
feat(server, ui): Fix PR
DelaunayAlex Oct 29, 2024
583c67c
feat(server): Add proxy
DelaunayAlex Oct 30, 2024
fb4efde
feat(ui): Update headers OAuth2
DelaunayAlex Nov 4, 2024
d8b7122
feat(ui): Update headers OAuth2
DelaunayAlex Nov 4, 2024
0e7caa2
feat(ui): SSO : Replace idToken with accessToken
DelaunayAlex Nov 6, 2024
975bf19
feat(ui, server): Ui parameter via server, add logo sso
DelaunayAlex Nov 6, 2024
d4029d4
[WIP] feat(ui, server): add param id_token_hint
DelaunayAlex Nov 6, 2024
562b35b
[WIP] feat(ui, server): add param id_token_hint
DelaunayAlex Nov 6, 2024
5b6fcc3
feat(ui): fix logout sso
DelaunayAlex Nov 7, 2024
4645511
feat(ui): SSO : Fix redirect uri
DelaunayAlex Nov 12, 2024
8fb7b70
feat(ui): fix retry sso
DelaunayAlex Nov 12, 2024
c7d26f2
feat(ui): fix test
DelaunayAlex Nov 13, 2024
56ccf36
feat(ui): fix PR
DelaunayAlex Nov 14, 2024
33c2a05
feat(ui): fix PR
DelaunayAlex Nov 19, 2024
95e6a5d
chore(): Allow to test sso with a local-dev server running on 8443
boddissattva Nov 20, 2024
8f51a23
chore(): Clean and fix flaky test
boddissattva Nov 20, 2024
36ddfb2
chore(): Fix flaky test
boddissattva Nov 20, 2024
5a38e60
feat(ui, server): Alert message when sso auth fails, fix PR
DelaunayAlex Nov 25, 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
Prev Previous commit
Next Next commit
feat(ui): Use app initializer
DelaunayAlex committed Nov 19, 2024

Verified

This commit was signed with the committer’s verified signature.
aumetra Aumetra Weisman
commit 1fa05b04fde91eb15384cf9e2782b21d77138188
28 changes: 10 additions & 18 deletions chutney/ui/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -27,9 +27,9 @@ import { BsModalService, ModalModule } from 'ngx-bootstrap/modal';
import { ThemeService } from '@core/theme/theme.service';
import { DefaultMissingTranslationHandler, HttpLoaderFactory } from '@core/initializer/app.translate.factory';
import { themeInitializer } from '@core/initializer/theme.initializer';
import { OAuthModule, OAuthService } from 'angular-oauth2-oidc';
import { SsoService } from '@core/services/sso.service';
import { tap } from 'rxjs';
import { OAuthModule } from 'angular-oauth2-oidc';
import { ssoInitializer } from "@core/initializer/sso.initializer";
import { SsoService } from "@core/services/sso.service";

@NgModule({
declarations: [
@@ -71,25 +71,17 @@ import { tap } from 'rxjs';
useFactory: themeInitializer,
deps: [ThemeService],
multi: true
},
{
provide: APP_INITIALIZER,
useFactory: ssoInitializer,
deps: [SsoService],
multi: true
}
],
bootstrap: [AppComponent]
})
export class ChutneyAppModule {

constructor(private oauthService: OAuthService, private ssoOpenIdConnectService: SsoService) {
this.configureOAuth();
}

private configureOAuth() {
this.ssoOpenIdConnectService.fetchSsoConfig().pipe(
tap(ssoConfig => {
this.oauthService.configure(ssoConfig)
this.oauthService.loadDiscoveryDocumentAndTryLogin();
})
).subscribe()
}
}
export class ChutneyAppModule {}



Original file line number Diff line number Diff line change
@@ -56,7 +56,6 @@ export class LoginComponent implements OnDestroy, OnInit {
if (this.loginService.isAuthenticated()) {
this.loginService.navigateAfterLogin();
}
this.ssoService.fetchSsoConfig()
}

ngOnDestroy() {
12 changes: 12 additions & 0 deletions chutney/ui/src/app/core/initializer/sso.initializer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-FileCopyrightText: 2017-2024 Enedis
*
* SPDX-License-Identifier: Apache-2.0
*
*/

import { SsoService } from "@core/services/sso.service";

export function ssoInitializer(ssoOpenIdConnectService: SsoService): () => void {
return () => ssoOpenIdConnectService.fetchSsoConfig()
}
12 changes: 8 additions & 4 deletions chutney/ui/src/app/core/services/sso.service.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import { HttpClient } from '@angular/common/http';
import { AuthConfig, OAuthService } from 'angular-oauth2-oidc';
import { environment } from '@env/environment';
import { Observable, map } from 'rxjs';
import {Observable, map, tap} from 'rxjs';
import { Injectable } from '@angular/core';

interface SsoAuthConfig {
@@ -34,8 +34,8 @@ export class SsoService {

constructor(private oauthService: OAuthService, private http: HttpClient) {}

fetchSsoConfig(): Observable<AuthConfig> {
return this.http.get<SsoAuthConfig>(environment.backend + this.resourceUrl).pipe(
fetchSsoConfig(): void {
this.http.get<SsoAuthConfig>(environment.backend + this.resourceUrl).pipe(
map(ssoConfig => {
this.ssoConfig = ssoConfig
return {
@@ -47,8 +47,12 @@ export class SsoService {
dummyClientSecret: ssoConfig.clientSecret,
oidc: ssoConfig.oidc
}
}),
tap(ssoConfig => {
this.oauthService.configure(ssoConfig)
this.oauthService.loadDiscoveryDocumentAndTryLogin();
})
)
).subscribe()
}

login() {