feat: add auth support (default and paia)

This commit is contained in:
Michel Jonathan Schmitz
2022-01-24 18:43:00 +00:00
committed by Jovan Krunić
parent 046a95ba1d
commit b5f239ea4e
85 changed files with 3626 additions and 119 deletions

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
*/
import {
StorageBackend,
Requestor,
AuthorizationServiceConfiguration,
} from '@openid/appauth';
import {Browser} from 'ionic-appauth';
import {environment} from 'src/environments/environment';
import {DefaultAuthService} from '../default-auth.service';
import {PAIAAuthService} from '../paia/paia-auth.service';
export const authFactory = (
requestor: Requestor,
browser: Browser,
storage: StorageBackend,
) => {
const authService = new DefaultAuthService(browser, storage, requestor);
authService.authConfig = environment.oauth2.client.his;
authService.localConfiguration = new AuthorizationServiceConfiguration(
environment.oauth2.service.his,
);
return authService;
};
export const paiaAuthFactory = (
requestor: Requestor,
browser: Browser,
storage: StorageBackend,
) => {
const authService = new PAIAAuthService(browser, storage, requestor);
authService.authConfig = environment.oauth2.client.paia;
authService.localConfiguration = new AuthorizationServiceConfiguration(
environment.oauth2.service.paia,
);
return authService;
};