argos/dmp-frontend/src/app/core/services/saml-login.service.ts

34 lines
1.4 KiB
TypeScript
Raw Normal View History

import { HttpHeaders, HttpClient } from '@angular/common/http';
2022-04-28 11:03:01 +02:00
import { Injectable } from '@angular/core';
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()
export class SamlLoginService extends BaseComponent {
2022-04-28 11:03:01 +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') : '';
}
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
}
}