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