2023-06-13 08:48:54 +02:00
|
|
|
import { HttpHeaders, HttpClient } from '@angular/common/http';
|
2022-04-28 11:03:01 +02:00
|
|
|
import { Injectable } from '@angular/core';
|
2023-06-13 08:48:54 +02:00
|
|
|
import { ConfigurationService } from './configuration/configuration.service';
|
|
|
|
import { BaseHttpService } from './http/base-http.service';
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
2022-04-28 11:03:01 +02:00
|
|
|
|
|
|
|
@Injectable()
|
2023-06-13 08:48:54 +02:00
|
|
|
export class SamlLoginService extends BaseComponent {
|
2022-04-28 11:03:01 +02:00
|
|
|
|
2023-06-13 08:48:54 +02:00
|
|
|
private actionUrl: string;
|
|
|
|
private headers = new HttpHeaders();
|
|
|
|
|
|
|
|
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
|
|
|
|
super();
|
|
|
|
this.actionUrl = configurationService.server + 'saml2/';
|
|
|
|
}
|
2022-04-28 11:03:01 +02:00
|
|
|
|
|
|
|
resolveConfigurableLoginId(relayState: string): string {
|
|
|
|
const decoded = decodeURIComponent(relayState);
|
|
|
|
const routeParams = new URLSearchParams(decoded);
|
|
|
|
return routeParams.has('configurableLoginId') ? routeParams.get('configurableLoginId') : undefined;
|
|
|
|
}
|
|
|
|
resolveSpId(relayState: string): string {
|
|
|
|
const decoded = decodeURIComponent(relayState);
|
|
|
|
const routeParams = new URLSearchParams(decoded);
|
|
|
|
return routeParams.has('spId') ? routeParams.get('spId') : '';
|
|
|
|
}
|
2023-06-13 08:48:54 +02:00
|
|
|
|
|
|
|
getAuthnRequest(configurableLoginId: string): Observable<string> {
|
|
|
|
return this.http.get<string>(this.actionUrl + 'authnRequest/' + configurableLoginId, { headers: this.headers });
|
2022-04-28 11:03:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|