diff --git a/src/app/_helpers/data/sample-configuration.ts b/src/app/_helpers/data/sample-configuration.ts index fadcf7fc..63d82eb2 100644 --- a/src/app/_helpers/data/sample-configuration.ts +++ b/src/app/_helpers/data/sample-configuration.ts @@ -12,7 +12,7 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {SCBackendAggregationConfiguration, SCThingType} from '@openstapps/core'; +import {SCAuthorizationProvider, SCBackendAggregationConfiguration, SCThingType} from '@openstapps/core'; // provides sample aggregations to be used in tests or backendless development export const sampleAggregations: SCBackendAggregationConfiguration[] = [ @@ -65,3 +65,27 @@ export const sampleAggregations: SCBackendAggregationConfiguration[] = [ fieldName: 'type', }, ]; + +export const sampleAuthConfiguration: { + default: SCAuthorizationProvider; + paia: SCAuthorizationProvider; + } = { + default: { + client: {clientId: '', scopes: '', url: ''}, + endpoints: { + authorization: '', + mapping: {id: '', name: ''}, + token: '', + userinfo: '', + }, + }, + paia: { + client: {clientId: '', scopes: '', url: ''}, + endpoints: { + authorization: '', + mapping: {id: '', name: ''}, + token: '', + userinfo: '', + }, + }, + }; diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index f6282b75..f9be438d 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -28,6 +28,7 @@ import {SettingsProvider} from './modules/settings/settings.provider'; import {NGXLogger} from 'ngx-logger'; import {RouterTestingModule} from '@angular/router/testing'; import {ScheduleSyncService} from './modules/background/schedule/schedule-sync.service'; +import {sampleAuthConfiguration} from './_helpers/data/sample-configuration'; describe('AppComponent', () => { let platformReadySpy: any; @@ -38,7 +39,6 @@ describe('AppComponent', () => { let configProvider: jasmine.SpyObj; let ngxLogger: jasmine.SpyObj; let scheduleSyncServiceSpy: jasmine.SpyObj; - let platformIsSpy; beforeEach( @@ -65,7 +65,15 @@ describe('AppComponent', () => { 'getDifferences', 'postDifferencesNotification', ]); - configProvider = jasmine.createSpyObj('ConfigProvider', ['init']); + configProvider = jasmine.createSpyObj('ConfigProvider', [ + 'init', + 'getAnyValue', + ]); + configProvider.getAnyValue = jasmine + .createSpy() + .and.callFake(function () { + return sampleAuthConfiguration; + }); ngxLogger = jasmine.createSpyObj('NGXLogger', ['log', 'error', 'warn']); TestBed.configureTestingModule({ diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 54198d77..fd3d2e64 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -22,9 +22,9 @@ import {ConfigProvider} from './modules/config/config.provider'; import {SettingsProvider} from './modules/settings/settings.provider'; import {PAIAAuthService} from './modules/auth/paia/paia-auth.service'; import {DefaultAuthService} from './modules/auth/default-auth.service'; -import {environment} from '../environments/environment'; import {AuthHelperService} from './modules/auth/auth-helper.service'; import {ScheduleSyncService} from './modules/background/schedule/schedule-sync.service'; +import {environment} from '../environments/environment'; /** * TODO @@ -88,7 +88,7 @@ export class AppComponent implements AfterContentInit { async initializeApp() { App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => { this.zone.run(() => { - const slug = event.url.split(environment.appDomain).pop(); + const slug = event.url.split(environment.app_host).pop(); if (slug) { this.router.navigateByUrl(slug); } diff --git a/src/app/modules/auth/auth-guard.service.ts b/src/app/modules/auth/auth-guard.service.ts index afce0827..2d59c885 100644 --- a/src/app/modules/auth/auth-guard.service.ts +++ b/src/app/modules/auth/auth-guard.service.ts @@ -3,7 +3,7 @@ import {CanActivate, Router, RouterStateSnapshot} from '@angular/router'; import {DefaultAuthService} from './default-auth.service'; import {PAIAAuthService} from './paia/paia-auth.service'; import {IAuthService} from 'ionic-appauth'; -import {ActivatedAuthRouteSnapshot} from './auth-routes'; +import {ActivatedProtectedRouteSnapshot} from './protected.routes'; @Injectable({ providedIn: 'root', @@ -18,7 +18,7 @@ export class AuthGuardService implements CanActivate { ) {} public async canActivate( - route: ActivatedAuthRouteSnapshot, + route: ActivatedProtectedRouteSnapshot, _state: RouterStateSnapshot, ) { switch (route.data.authProvider) { diff --git a/src/app/modules/auth/auth-helper.service.ts b/src/app/modules/auth/auth-helper.service.ts index ef2d71d9..00f6e9a7 100644 --- a/src/app/modules/auth/auth-helper.service.ts +++ b/src/app/modules/auth/auth-helper.service.ts @@ -1,20 +1,33 @@ import {Injectable} from '@angular/core'; -import { - SCAuthorizationProviderType, - SCUserConfiguration, - userMapping, -} from '../profile/user'; import {IPAIAAuthAction} from './paia/paia-auth-action'; import {AuthActions, IAuthAction} from 'ionic-appauth'; import {TranslateService} from '@ngx-translate/core'; import {JSONFile} from '@angular/cli/utilities/json-file'; import {JSONPath} from 'jsonpath-plus'; +import { + SCAuthorizationProvider, + SCAuthorizationProviderType, + SCUserConfiguration, + SCUserConfigurationMap, +} from '@openstapps/core'; +import {ConfigProvider} from '../config/config.provider'; @Injectable({ providedIn: 'root', }) export class AuthHelperService { - constructor(private translateService: TranslateService) {} + userConfigurationMap: SCUserConfigurationMap; + + constructor( + private translateService: TranslateService, + private configProvider: ConfigProvider, + ) { + this.userConfigurationMap = ( + this.configProvider.getAnyValue('auth') as { + default: SCAuthorizationProvider; + } + ).default.endpoints.mapping; + } public getAuthMessage( provider: SCAuthorizationProviderType, @@ -38,9 +51,11 @@ export class AuthHelperService { getUserFromUserInfo(userInfo: JSONFile) { const user: SCUserConfiguration = {id: '', name: '', role: 'student'}; - for (const key in userMapping) { + for (const key in this.userConfigurationMap) { user[key as keyof SCUserConfiguration] = JSONPath({ - path: userMapping[key as keyof SCUserConfiguration] as string, + path: this.userConfigurationMap[ + key as keyof SCUserConfiguration + ] as string, json: userInfo, })[0]; } diff --git a/src/app/modules/auth/auth-paths.ts b/src/app/modules/auth/auth-paths.ts new file mode 100644 index 00000000..3471c846 --- /dev/null +++ b/src/app/modules/auth/auth-paths.ts @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2022 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {SCAuthorizationProviderType} from '@openstapps/core'; + +export const authPaths: { + [key in SCAuthorizationProviderType]: {redirect_path: string}; +} = { + default: { + redirect_path: 'auth/callback', + }, + paia: { + redirect_path: 'auth/paia/callback', + }, +}; diff --git a/src/app/modules/auth/auth-routing.module.ts b/src/app/modules/auth/auth-routing.module.ts index 6591c5bf..20dc2afb 100644 --- a/src/app/modules/auth/auth-routing.module.ts +++ b/src/app/modules/auth/auth-routing.module.ts @@ -17,10 +17,17 @@ import {RouterModule, Routes} from '@angular/router'; import {NgModule} from '@angular/core'; import {AuthCallbackPageComponent} from './auth-callback/page/auth-callback-page.component'; import {PAIAAuthCallbackPageComponent} from './paia/auth-callback/page/auth-callback-page.component'; +import {authPaths} from './auth-paths'; const authRoutes: Routes = [ - {path: 'auth/callback', component: AuthCallbackPageComponent}, - {path: 'auth/paia/callback', component: PAIAAuthCallbackPageComponent}, + { + path: authPaths.default.redirect_path, + component: AuthCallbackPageComponent, + }, + { + path: authPaths.paia.redirect_path, + component: PAIAAuthCallbackPageComponent, + }, ]; /** diff --git a/src/app/modules/auth/auth.module.ts b/src/app/modules/auth/auth.module.ts index acc79b9f..7a173129 100644 --- a/src/app/modules/auth/auth.module.ts +++ b/src/app/modules/auth/auth.module.ts @@ -13,6 +13,7 @@ import {AuthRoutingModule} from './auth-routing.module'; import {TranslateModule} from '@ngx-translate/core'; import {AuthCallbackPageComponent} from './auth-callback/page/auth-callback-page.component'; import {PAIAAuthCallbackPageComponent} from './paia/auth-callback/page/auth-callback-page.component'; +import {ConfigProvider} from '../config/config.provider'; @NgModule({ declarations: [AuthCallbackPageComponent, PAIAAuthCallbackPageComponent], @@ -35,12 +36,12 @@ import {PAIAAuthCallbackPageComponent} from './paia/auth-callback/page/auth-call { provide: DefaultAuthService, useFactory: authFactory, - deps: [Requestor, Browser, StorageBackend], + deps: [Requestor, Browser, StorageBackend, ConfigProvider], }, { provide: PAIAAuthService, useFactory: paiaAuthFactory, - deps: [Requestor, Browser, StorageBackend], + deps: [Requestor, Browser, StorageBackend, ConfigProvider], }, ], }) diff --git a/src/app/modules/auth/factories/auth.factory.ts b/src/app/modules/auth/factories/auth.factory.ts index 2c003bad..186bccbf 100644 --- a/src/app/modules/auth/factories/auth.factory.ts +++ b/src/app/modules/auth/factories/auth.factory.ts @@ -17,21 +17,36 @@ import { StorageBackend, Requestor, AuthorizationServiceConfiguration, + AuthorizationServiceConfigurationJson, } from '@openid/appauth'; -import {Browser} from 'ionic-appauth'; -import {environment} from 'src/environments/environment'; -import {DefaultAuthService} from '../default-auth.service'; +import {Browser, IAuthConfig} from 'ionic-appauth'; import {PAIAAuthService} from '../paia/paia-auth.service'; +import config from '../../../../../capacitor.config'; +import {ConfigProvider} from '../../config/config.provider'; +import { + SCAuthorizationProvider, + SCAuthorizationProviderType, +} from '@openstapps/core'; +import {DefaultAuthService} from '../default-auth.service'; +import {Capacitor} from '@capacitor/core'; +import {authPaths} from '../auth-paths'; +import {environment} from '../../../../environments/environment'; export const authFactory = ( requestor: Requestor, browser: Browser, storage: StorageBackend, + configProvider: ConfigProvider, ) => { const authService = new DefaultAuthService(browser, storage, requestor); - authService.authConfig = environment.oauth2.client.his; + const authConfig = configProvider.getAnyValue('auth') as { + default: SCAuthorizationProvider; + }; + + authService.authConfig = getClientConfig('default', authConfig); + authService.localConfiguration = new AuthorizationServiceConfiguration( - environment.oauth2.service.his, + getEndpointsConfig('default', authConfig), ); return authService; @@ -41,12 +56,67 @@ export const paiaAuthFactory = ( requestor: Requestor, browser: Browser, storage: StorageBackend, + configProvider: ConfigProvider, ) => { const authService = new PAIAAuthService(browser, storage, requestor); - authService.authConfig = environment.oauth2.client.paia; + const authConfig = configProvider.getAnyValue('auth') as { + paia: SCAuthorizationProvider; + }; + + authService.authConfig = getClientConfig('paia', authConfig); + authService.localConfiguration = new AuthorizationServiceConfiguration( - environment.oauth2.service.paia, + getEndpointsConfig('paia', authConfig), ); return authService; }; + +/** + * Get configuration of an OAuth2 client + */ +function getClientConfig( + providerType: SCAuthorizationProviderType, + authConfig: { + default?: SCAuthorizationProvider; + paia?: SCAuthorizationProvider; + }, +): IAuthConfig { + const providerConfig = authConfig[providerType] as SCAuthorizationProvider; + return { + end_session_redirect_url: '', + pkce: true, + scopes: providerConfig.client.scopes, + server_host: providerConfig.client.url, + client_id: providerConfig.client.clientId, + redirect_url: getRedirectUrl(authPaths[providerType].redirect_path), + }; +} + +/** + * Get configuration about endpoints of an OAuth2 server + */ +function getEndpointsConfig( + providerType: SCAuthorizationProviderType, + authConfig: { + default?: SCAuthorizationProvider; + paia?: SCAuthorizationProvider; + }, +): AuthorizationServiceConfigurationJson { + const providerConfig = authConfig[providerType] as SCAuthorizationProvider; + return { + authorization_endpoint: providerConfig.endpoints.authorization, + end_session_endpoint: providerConfig.endpoints.endSession, + revocation_endpoint: providerConfig.endpoints.revoke ?? '', + token_endpoint: providerConfig.endpoints.token, + userinfo_endpoint: providerConfig.endpoints.userinfo, + }; +} + +/** + * Return a URL of the app, depending on the platform where it is running + */ +function getRedirectUrl(routePath: string): string { + const appSchema = Capacitor.isNativePlatform() ? config.appId : 'https'; + return `${appSchema}://${environment.app_host}/${routePath}`; +} diff --git a/src/app/modules/auth/auth-routes.ts b/src/app/modules/auth/protected.routes.ts similarity index 73% rename from src/app/modules/auth/auth-routes.ts rename to src/app/modules/auth/protected.routes.ts index 768758d6..e5c4f100 100644 --- a/src/app/modules/auth/auth-routes.ts +++ b/src/app/modules/auth/protected.routes.ts @@ -14,9 +14,9 @@ */ import {ActivatedRouteSnapshot, Data, Route} from '@angular/router'; -import {SCAuthorizationProviderType} from '../profile/user'; +import {SCAuthorizationProviderType} from '@openstapps/core'; -export interface AuthRoute extends Route { +export interface ProtectedRoute extends Route { data: { authProvider: SCAuthorizationProviderType; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -24,8 +24,8 @@ export interface AuthRoute extends Route { }; } -export class ActivatedAuthRouteSnapshot extends ActivatedRouteSnapshot { - data: Data & {authProvider: AuthRoute['data']['authProvider']}; +export class ActivatedProtectedRouteSnapshot extends ActivatedRouteSnapshot { + data: Data & {authProvider: ProtectedRoute['data']['authProvider']}; } -export type AuthRoutes = AuthRoute[]; +export type ProtectedRoutes = ProtectedRoute[]; diff --git a/src/app/modules/config/config.provider.ts b/src/app/modules/config/config.provider.ts index fae3a31d..bb2f06e7 100644 --- a/src/app/modules/config/config.provider.ts +++ b/src/app/modules/config/config.provider.ts @@ -117,6 +117,18 @@ export class ConfigProvider { throw new ConfigValueNotAvailable(attribute); } + /** + * Returns a value of the configuration (not only app configuration) + * + * @param attribute requested attribute from the configuration + */ + public getAnyValue(attribute: keyof SCIndexResponse) { + if (typeof this.config[attribute] !== 'undefined') { + return this.config[attribute]; + } + throw new ConfigValueNotAvailable(attribute); + } + /** * Initialises the ConfigProvider * diff --git a/src/app/modules/library/library.module.ts b/src/app/modules/library/library.module.ts index 1ffeb442..f0cd282a 100644 --- a/src/app/modules/library/library.module.ts +++ b/src/app/modules/library/library.module.ts @@ -5,7 +5,6 @@ import {IonicModule} from '@ionic/angular'; import {RouterModule, Routes} from '@angular/router'; import {TranslateModule} from '@ngx-translate/core'; import {LibraryAccountPageComponent} from './account/account.page'; -import {AuthRoutes} from '../auth/auth-routes'; import {ProfilePageComponent} from './account/profile/profile-page.component'; import {CheckedOutPageComponent} from './account/checked-out/checked-out-page.component'; import {HoldsAndReservationsPageComponent} from './account/holds-and-reservations/holds-and-reservations-page.component'; @@ -13,8 +12,9 @@ import {FinesPageComponent} from './account/fines/fines-page.component'; import {PAIAItemComponent} from './account/elements/paia-item/paiaitem.component'; import {FirstLastNamePipe} from './account/first-last-name.pipe'; import {AuthGuardService} from '../auth/auth-guard.service'; +import {ProtectedRoutes} from '../auth/protected.routes'; -const routes: AuthRoutes | Routes = [ +const routes: ProtectedRoutes | Routes = [ { path: 'library-account', component: LibraryAccountPageComponent, diff --git a/src/app/modules/menu/navigation/navigation.service.ts b/src/app/modules/menu/navigation/navigation.service.ts index 09d1b08f..22247438 100644 --- a/src/app/modules/menu/navigation/navigation.service.ts +++ b/src/app/modules/menu/navigation/navigation.service.ts @@ -22,20 +22,6 @@ export class NavigationService { this.logger.error(`error from loading menu entries: ${error}`); } - // TODO: move this menu item to the config (backend) - menu[1].items.unshift({ - icon: 'library', - route: '/library-account', - title: 'library account', - translations: { - de: { - title: 'Bibliothekskonto', - }, - en: { - title: 'Library account', - }, - }, - }); return menu; } } diff --git a/src/app/modules/profile/page/profile-page.component.spec.ts b/src/app/modules/profile/page/profile-page.component.spec.ts index 08e295eb..3a033777 100644 --- a/src/app/modules/profile/page/profile-page.component.spec.ts +++ b/src/app/modules/profile/page/profile-page.component.spec.ts @@ -20,12 +20,23 @@ import {RouterTestingModule} from '@angular/router/testing'; import {AuthModule} from '../../auth/auth.module'; import {ProfilePageComponent} from './profile-page.component'; import {TranslateModule} from '@ngx-translate/core'; +import {ConfigProvider} from '../../config/config.provider'; +import {sampleAuthConfiguration} from '../../../_helpers/data/sample-configuration'; describe('ProfilePage', () => { let component: ProfilePageComponent; let fixture: ComponentFixture; + let configProvider: ConfigProvider; beforeEach(async(() => { + configProvider = jasmine.createSpyObj('ConfigProvider', [ + 'init', + 'getAnyValue', + ]); + configProvider.getAnyValue = jasmine.createSpy().and.callFake(function () { + return sampleAuthConfiguration; + }); + TestBed.configureTestingModule({ declarations: [ProfilePageComponent], imports: [ @@ -34,6 +45,7 @@ describe('ProfilePage', () => { AuthModule, TranslateModule.forRoot(), ], + providers: [{provide: ConfigProvider, useValue: configProvider}], schemas: [CUSTOM_ELEMENTS_SCHEMA], }).compileComponents(); })); diff --git a/src/app/modules/profile/page/profile-page.component.ts b/src/app/modules/profile/page/profile-page.component.ts index 3a675e93..d20c8974 100644 --- a/src/app/modules/profile/page/profile-page.component.ts +++ b/src/app/modules/profile/page/profile-page.component.ts @@ -18,9 +18,12 @@ import {IonicUserInfoHandler} from 'ionic-appauth'; import {DefaultAuthService} from '../../auth/default-auth.service'; import {Requestor, TokenResponse} from '@openid/appauth'; import {PAIAAuthService} from '../../auth/paia/paia-auth.service'; -import {SCAuthorizationProviderType, SCUserConfiguration} from '../user'; import {Subscription} from 'rxjs'; import {AuthHelperService} from '../../auth/auth-helper.service'; +import { + SCAuthorizationProviderType, + SCUserConfiguration, +} from '@openstapps/core'; @Component({ selector: 'app-home', diff --git a/src/app/modules/profile/user.ts b/src/app/modules/profile/user.ts deleted file mode 100644 index 7ef39ffb..00000000 --- a/src/app/modules/profile/user.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2022 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -/** - * TODO: Take it from the StApps Core - */ -import {SCAcademicPriceGroup} from '@openstapps/core'; - -/** - * A user configuration - */ -export interface SCUserConfiguration { - /** - * User's e-mail - */ - email?: string; - - /** - * User's family name - */ - familyName?: string; - - /** - * User's given name - */ - givenName?: string; - - /** - * ID given to the user - */ - id: string; - - /** - * The complete name of the user combining all the parts of the name into one - */ - name: string; - - /** - * Role assigned to the user - */ - role: keyof SCAcademicPriceGroup; - - /** - * Student ID given to the user - */ - studentId?: string; -} - -/** - * TODO: Take it from the backend's config - */ -type mapping = {[key in keyof SCUserConfiguration]: string}; - -/** - * TODO: Take it from the backend's config - */ -export const userMapping: mapping = { - id: 'id', - name: 'sn', - role: 'attributes.eduPersonPrimaryAffiliation', - email: 'attributes.mailPrimaryAddress', - studentId: 'attributes.employeeNumber', - givenName: 'attributes.givenName', - familyName: 'attributes.sn', -}; - -/** - * TODO: Take it from the StApps Core - */ -export type SCAuthorizationProviderType = 'default' | 'paia'; diff --git a/src/environments/environment.fake.ts b/src/environments/environment.fake.ts index 4e488b03..2672630e 100644 --- a/src/environments/environment.fake.ts +++ b/src/environments/environment.fake.ts @@ -16,65 +16,14 @@ // The build system defaults to the dev environment which uses `environment.ts`, but if you do // `ng build --env=prod` then `environment.prod.ts` will be used instead. // The list of which env maps to which file can be found in `.angular-cli.json`. -import {AuthorizationServiceConfigurationJson} from '@openid/appauth'; -import {IAuthConfig} from 'ionic-appauth'; -// import config from 'capacitor.config'; - -const appDomain = 'mobile.app.uni-frankfurt.de'; export const environment = { backend_url: 'https://mobile.server.uni-frankfurt.de', daia_url: 'https://daia.hebis.de/DAIA2/UB_Frankfurt', - appDomain: 'mobile.app.uni-frankfurt.de', + app_host: 'mobile.app.uni-frankfurt.de', backend_version: '2.0.0', use_fake_backend: true, production: false, - oauth2: { - client: { - his: { - client_id: '1cac3f99-33fa-4234-8438-979f07e0cdab', - client_secret: 'CLIENT_SECRET', - server_host: 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0', - redirect_url: `https://${appDomain}/auth/callback`, - scopes: '', - pkce: true, - } as IAuthConfig, - paia: { - client_id: '', - client_secret: '', - server_host: - 'https://hds.hebis.de/Shibboleth.sso/UBFFM?target=https://hds.hebis.de/ubffm/paia_login_stub.php', - // TODO: Use Custom URL Scheme (ideally bundle ID from capacitor.config) - redirect_url: `https://${appDomain}/auth/paia/callback`, - scopes: '', - pkce: true, - } as IAuthConfig, - }, - service: { - his: { - authorization_endpoint: - 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0/authorize', - token_endpoint: - 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0/accessToken', - userinfo_endpoint: - 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0/profile', - } as AuthorizationServiceConfigurationJson, - paia: { - authorization_endpoint: - 'https://hds.hebis.de/Shibboleth.sso/UBFFM?target=https://hds.hebis.de/ubffm/paia_login_stub.php', - token_endpoint: 'https://hds.hebis.de:8443/auth/login', - userinfo_endpoint: 'https://hds.hebis.de:8443/core', - } as AuthorizationServiceConfigurationJson, - }, - endpointMappings: { - userinfo: { - id: 'employeeNumber', - given_name: 'givenName', - family_name: 'sn', - email: 'mailPrimaryAddress', - }, - }, - }, }; /* diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 6df7ffcb..ce7429b0 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -16,65 +16,14 @@ // The build system defaults to the dev environment which uses `environment.ts`, but if you do // `ng build --env=prod` then `environment.prod.ts` will be used instead. // The list of which env maps to which file can be found in `.angular-cli.json`. -import {AuthorizationServiceConfigurationJson} from '@openid/appauth'; -import {IAuthConfig} from 'ionic-appauth'; -// import config from 'capacitor.config'; - -const appDomain = 'mobile.app.uni-frankfurt.de'; export const environment = { backend_url: 'https://mobile.server.uni-frankfurt.de', daia_url: 'https://daia.hebis.de/DAIA2/UB_Frankfurt', - appDomain: 'mobile.app.uni-frankfurt.de', + app_host: 'mobile.app.uni-frankfurt.de', backend_version: '2.0.0', use_fake_backend: false, - production: false, - oauth2: { - client: { - his: { - client_id: '1cac3f99-33fa-4234-8438-979f07e0cdab', - client_secret: 'CLIENT_SECRET', - server_host: 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0', - redirect_url: `https://${appDomain}/auth/callback`, - scopes: '', - pkce: true, - } as IAuthConfig, - paia: { - client_id: '', - client_secret: '', - server_host: - 'https://hds.hebis.de/Shibboleth.sso/UBFFM?target=https://hds.hebis.de/ubffm/paia_login_stub.php', - // TODO: Use Custom URL Scheme (ideally bundle ID from capacitor.config) - redirect_url: `https://${appDomain}/auth/paia/callback`, - scopes: '', - pkce: true, - } as IAuthConfig, - }, - service: { - his: { - authorization_endpoint: - 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0/authorize', - token_endpoint: - 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0/accessToken', - userinfo_endpoint: - 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0/profile', - } as AuthorizationServiceConfigurationJson, - paia: { - authorization_endpoint: - 'https://hds.hebis.de/Shibboleth.sso/UBFFM?target=https://hds.hebis.de/ubffm/paia_login_stub.php', - token_endpoint: 'https://hds.hebis.de:8443/auth/login', - userinfo_endpoint: 'https://hds.hebis.de:8443/core', - } as AuthorizationServiceConfigurationJson, - }, - endpointMappings: { - userinfo: { - id: 'employeeNumber', - given_name: 'givenName', - family_name: 'sn', - email: 'mailPrimaryAddress', - }, - }, - }, + production: true, }; /* diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 158e7666..4053a926 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -16,65 +16,14 @@ // The build system defaults to the dev environment which uses `environment.ts`, but if you do // `ng build --env=prod` then `environment.prod.ts` will be used instead. // The list of which env maps to which file can be found in `.angular-cli.json`. -import {AuthorizationServiceConfigurationJson} from '@openid/appauth'; -import {IAuthConfig} from 'ionic-appauth'; -// import config from 'capacitor.config'; - -const appDomain = 'mobile.app.uni-frankfurt.de'; export const environment = { backend_url: 'https://mobile.server.uni-frankfurt.de', daia_url: 'https://daia.hebis.de/DAIA2/UB_Frankfurt', - appDomain: 'mobile.app.uni-frankfurt.de', + app_host: 'mobile.app.uni-frankfurt.de', backend_version: '2.0.0', use_fake_backend: false, production: false, - oauth2: { - client: { - his: { - client_id: '1cac3f99-33fa-4234-8438-979f07e0cdab', - client_secret: '', - server_host: 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0', - redirect_url: `https://${appDomain}/auth/callback`, - scopes: '', - pkce: true, - } as IAuthConfig, - paia: { - client_id: '', - client_secret: '', - server_host: - 'https://hds.hebis.de/Shibboleth.sso/UBFFM?target=https://hds.hebis.de/ubffm/paia_login_stub.php', - // TODO: Use Custom URL Scheme (ideally bundle ID from capacitor.config) - redirect_url: `https://${appDomain}/auth/paia/callback`, - scopes: '', - pkce: true, - } as IAuthConfig, - }, - service: { - his: { - authorization_endpoint: - 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0/authorize', - token_endpoint: - 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0/accessToken', - userinfo_endpoint: - 'https://cas.rz.uni-frankfurt.de/cas/oauth2.0/profile', - } as AuthorizationServiceConfigurationJson, - paia: { - authorization_endpoint: - 'https://hds.hebis.de/Shibboleth.sso/UBFFM?target=https://hds.hebis.de/ubffm/paia_login_stub.php', - token_endpoint: 'https://hds.hebis.de:8443/auth/login', - userinfo_endpoint: 'https://hds.hebis.de:8443/core', - } as AuthorizationServiceConfigurationJson, - }, - endpointMappings: { - userinfo: { - id: 'employeeNumber', - given_name: 'givenName', - family_name: 'sn', - email: 'mailPrimaryAddress', - }, - }, - }, }; /*