diff --git a/src/frontend/app/login/login.component.html b/src/frontend/app/login/login.component.html index 8e70622ce5c2f24395811860872f8f1c98736b56..1cd2f086472b5a1a341f210686e9c48c8e459e0f 100644 --- a/src/frontend/app/login/login.component.html +++ b/src/frontend/app/login/login.component.html @@ -6,20 +6,22 @@ <div style="color: white;font-size: 14px;" [innerHTML]="loginMessage | safeHtml"></div> <p style="color: white;font-size: 14px;font-weight: bold;">{{applicationName}}</p> <div style="padding-left: 30px;padding-right: 30px;"> - <mat-form-field class="input-row login" appearance="outline" style="padding-bottom: 0px;"> + <mat-form-field *ngIf="['cas'].indexOf(authService.authMode) === -1" class="input-row login" appearance="outline" style="padding-bottom: 0px;"> <input id="login" name="login" matInput [placeholder]="this.translate.instant('lang.id')" formControlName="login" type="text"> </mat-form-field> - <mat-form-field class="input-row" appearance="outline"> + <mat-form-field *ngIf="['cas'].indexOf(authService.authMode) === -1" class="input-row" appearance="outline"> <input id="password" name="password" matInput [placeholder]="this.translate.instant('lang.password')" type="password" formControlName="password"> <mat-hint align="end" *ngIf="authService.authMode === 'standard'"><a routerLink="/forgot-password" class="infoLogin">{{'lang.forgotPassword' | translate}} ?</a></mat-hint> - <mat-hint align="end" *ngIf="authService.authMode !== 'ldap'"><span + <mat-hint align="end" *ngIf="authService.authMode === 'ldap'"><span class="infoLogin">{{'lang.' + authService.authMode + 'Enabled' | translate}}</span></mat-hint> </mat-form-field> </div> - + <div *ngIf="['cas'].indexOf(authService.authMode) > -1" class="alert-message alert-message-info" role="alert" style="max-width: 100%;"> + {{'lang.' + authService.authMode + 'Enabled' | translate}} + </div> <button id="submit" type="submit" mat-stroked-button [disabled]="loginForm.invalid || loading" style="color: white;border-color: #24b0ed;background: #24b0ed;">{{'lang.LOGIN' | translate}}</button> </form> diff --git a/src/frontend/app/login/login.component.ts b/src/frontend/app/login/login.component.ts index 28330b66f014877d2003daf41003398dc6fba5e7..41b45674dd4f5075b16f605da64df2adc6caf856 100644 --- a/src/frontend/app/login/login.component.ts +++ b/src/frontend/app/login/login.component.ts @@ -63,13 +63,14 @@ export class LoginComponent implements OnInit { } } - onSubmit() { + onSubmit(ssoToken = null) { this.loading = true; this.http.post( '../rest/authenticate', { 'login': this.loginForm.get('login').value, - 'password': this.loginForm.get('password').value + 'password': this.loginForm.get('password').value, + 'ssoToken' : ssoToken }, { observe: 'response' @@ -114,10 +115,19 @@ export class LoginComponent implements OnInit { this.loginMessage = data.loginMessage; this.authService.setEvent('authenticationInformations'); - if (['cas', 'openid'].indexOf(this.authService.authMode) > -1) { + // FOR TEST + this.authService.authMode = 'cas'; + this.authService.authUrl = 'https://10.2.95.72:8443/cas-server-webapp-4.0.0/login?service=http://localhost/maarch_courrier_develop/cs_recette/dist/index.html#/login'; + + if (['cas', 'keycloak'].indexOf(this.authService.authMode) > -1) { this.loginForm.disable(); this.loginForm.setValidators(null); - this.onSubmit(); + const regex = /ticket=[.]*/g; + if (window.location.search.match(regex) !== null) { + this.onSubmit(window.location.search.substring(1, window.location.search.length)); + } else { + window.location.href = this.authService.authUrl; + } } }), finalize(() => this.showForm = true), diff --git a/src/frontend/service/auth.service.ts b/src/frontend/service/auth.service.ts index 9f23d81a7213596ce08fd86f889ed19d6f6df1a8..d913662d2df280efaf15b22c3045e2a0eff7f9fc 100644 --- a/src/frontend/service/auth.service.ts +++ b/src/frontend/service/auth.service.ts @@ -12,6 +12,7 @@ import { Observable, Subject } from 'rxjs'; export class AuthService { authMode: string = 'default'; + authUrl: string = ''; changeKey: boolean = null; user: any = {}; private eventAction = new Subject<any>(); diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json index 32812a74f244f9f782090cf4f879e1fa473f3215..2161345d57afd99a3f0700a631c800dce432ab16 100644 --- a/src/lang/lang-fr.json +++ b/src/lang/lang-fr.json @@ -2092,8 +2092,8 @@ "size": "Taille", "linkedMails": "Courrier(s) lié(s)", "ldapEnabled": "Ldap activé", - "openidEnabled": "Openid activé", - "casEnabled": "CAS activé", + "keycloakEnabled": "Authentification Keycloak activée", + "casEnabled": "Authentification CAS activée", "displayAsTechnicalData" : "Afficher en tant que donnée technique", "displayInForm" : "Afficher dans le formulaire", "technicalInformations" : "Informations techniques"