diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 7a049651..f3354666 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -25,7 +25,8 @@ export const environment = { keycloak: { url: '${KEYCLOAK_URL}', realm: '${KEYCLOAK_REALM}', - clientId: '${KEYCLOAK_CLIENT_ID}' + clientId: '${KEYCLOAK_CLIENT_ID}', + skipLoginPage: ${KEYCLOAK_SKIP_LOGIN} }, umami: { enabled: '${UMAMI_ENABLED}', diff --git a/webapp/src/app/core/header/header.component.ts b/webapp/src/app/core/header/header.component.ts index 00a031db..5d1b598c 100644 --- a/webapp/src/app/core/header/header.component.ts +++ b/webapp/src/app/core/header/header.component.ts @@ -5,6 +5,7 @@ import { HlmButtonModule } from '@spartan-ng/ui-button-helm'; import { SecurityStore } from '@app/core/security/security-store.service'; import { ThemeSwitcherComponent } from '@app/core/theme/theme-switcher.component'; import { RequestFeatureComponent } from './request-feature/request-feature.component'; +import { environment } from 'environments/environment'; @Component({ selector: 'app-header', @@ -23,6 +24,19 @@ export class HeaderComponent { } protected signIn() { - this.securityStore.signIn(); + if (environment.keycloak.skipLoginPage) { + const authUrl = + `${environment.keycloak.url}/realms/${environment.keycloak.realm}/protocol/openid-connect/auth` + + `?client_id=${encodeURIComponent(environment.keycloak.clientId)}` + + `&redirect_uri=${encodeURIComponent(environment.clientUrl)}` + + `&response_type=code` + + `&scope=openid` + + `&kc_idp_hint=${encodeURIComponent('github')}`; + + // Redirect the user to the Keycloak GitHub login + window.location.href = authUrl; + } else { + this.securityStore.signIn(); + } } } diff --git a/webapp/src/environments/environment.prod.ts b/webapp/src/environments/environment.prod.ts index f0033cc1..50220235 100644 --- a/webapp/src/environments/environment.prod.ts +++ b/webapp/src/environments/environment.prod.ts @@ -4,7 +4,8 @@ export const environment = { keycloak: { url: 'http://localhost:8081', realm: 'hephaestus', - clientId: 'hephaestus' + clientId: 'hephaestus', + skipLoginPage: false // If true, it will directly use github IDP for login }, umami: { enabled: false, diff --git a/webapp/src/environments/environment.ts b/webapp/src/environments/environment.ts index f0033cc1..023fa93f 100644 --- a/webapp/src/environments/environment.ts +++ b/webapp/src/environments/environment.ts @@ -4,7 +4,8 @@ export const environment = { keycloak: { url: 'http://localhost:8081', realm: 'hephaestus', - clientId: 'hephaestus' + clientId: 'hephaestus', + skipLoginPage: true // If true, it will directly use github IDP for login }, umami: { enabled: false,