mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-10-14 21:42:51 +00:00
WIP use oidc config model from core
This commit is contained in:
@@ -23,11 +23,6 @@ import {environment} from '../../../environments/environment';
|
||||
import {AUTH_REDIRECT_PATH} from './auth-paths';
|
||||
import type {AuthConfig} from './auth.provider';
|
||||
|
||||
export interface OidcEndpoints {
|
||||
userinfo?: string;
|
||||
endSession?: string;
|
||||
}
|
||||
|
||||
export const OFFLINE_ACCESS_SCOPE = 'offline_access';
|
||||
|
||||
/**
|
||||
@@ -91,26 +86,6 @@ export function getServiceConfiguration(
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the additional OIDC endpoints that AppAuth-JS does not expose
|
||||
* through AuthorizationServiceConfiguration.
|
||||
*/
|
||||
export function getOidcEndpoints(
|
||||
authConfig: {
|
||||
default: SCAuthorizationProvider;
|
||||
},
|
||||
): OidcEndpoints {
|
||||
const endpoints = authConfig.default.endpoints;
|
||||
|
||||
return {
|
||||
userinfo:
|
||||
endpoints.userinfo,
|
||||
|
||||
endSession:
|
||||
endpoints.endSession,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the OIDC redirect URL depending on the current platform.
|
||||
*/
|
||||
|
||||
@@ -42,16 +42,14 @@ import {
|
||||
TokenRequestJson,
|
||||
TokenResponse,
|
||||
} from '@openid/appauth';
|
||||
import {SCAuthorizationProvider} from '@openstapps/core';
|
||||
import {SCAuthorizationProvider, SCAuthorizationProviderEndpoints} from '@openstapps/core';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
|
||||
import {ConfigProvider} from '../config/config.provider';
|
||||
import {CapacitorAuthorizationRequestHandler} from './capacitor-authorization-request-handler';
|
||||
import {
|
||||
getClientConfig,
|
||||
getOidcEndpoints,
|
||||
getServiceConfiguration,
|
||||
OidcEndpoints,
|
||||
} from './auth.provider.methods';
|
||||
import {requestorFactory} from './factories/requestor.factory';
|
||||
import {storageFactory} from './factories/storage.factory';
|
||||
@@ -220,7 +218,11 @@ export class AuthProvider {
|
||||
private localConfiguration?:
|
||||
AuthorizationServiceConfiguration;
|
||||
|
||||
private oidcEndpoints?: OidcEndpoints;
|
||||
/**
|
||||
* Endpoints from the backend configuration. AppAuth's
|
||||
* AuthorizationServiceConfiguration has no userinfo / end-session.
|
||||
*/
|
||||
private endpoints?: SCAuthorizationProviderEndpoints;
|
||||
|
||||
private readonly authSubject =
|
||||
new BehaviorSubject<IAuthAction>({
|
||||
@@ -380,8 +382,8 @@ export class AuthProvider {
|
||||
this.localConfiguration =
|
||||
getServiceConfiguration(config);
|
||||
|
||||
this.oidcEndpoints =
|
||||
getOidcEndpoints(config);
|
||||
this.endpoints =
|
||||
config.default.endpoints;
|
||||
}
|
||||
|
||||
public async signIn(
|
||||
@@ -466,7 +468,7 @@ export class AuthProvider {
|
||||
await this.getValidToken(0);
|
||||
|
||||
const endpoint =
|
||||
this.oidcEndpoints?.userinfo;
|
||||
this.endpoints?.userinfo;
|
||||
|
||||
if (!endpoint) {
|
||||
throw new Error(
|
||||
@@ -511,7 +513,7 @@ export class AuthProvider {
|
||||
|
||||
public async getEndSessionEndpoint():
|
||||
Promise<string | undefined> {
|
||||
return this.oidcEndpoints
|
||||
return this.endpoints
|
||||
?.endSession;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user