Skip to content

Commit

Permalink
add option to skip keycloak login page
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Oct 6, 2024
1 parent 4e3677e commit 7a4ec5b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand Down
16 changes: 15 additions & 1 deletion webapp/src/app/core/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
}
}
}
3 changes: 2 additions & 1 deletion webapp/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7a4ec5b

Please sign in to comment.