mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
feat: add auth support (default and paia)
This commit is contained in:
committed by
Jovan Krunić
parent
046a95ba1d
commit
b5f239ea4e
52
src/app/modules/auth/factories/auth.factory.ts
Normal file
52
src/app/modules/auth/factories/auth.factory.ts
Normal 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;
|
||||
};
|
||||
9
src/app/modules/auth/factories/browser.factory.ts
Normal file
9
src/app/modules/auth/factories/browser.factory.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import {Platform} from '@ionic/angular';
|
||||
import {DefaultBrowser} from 'ionic-appauth';
|
||||
import {CapacitorBrowser} from 'ionic-appauth/lib/capacitor';
|
||||
|
||||
export const browserFactory = (platform: Platform) => {
|
||||
return platform.is('capacitor')
|
||||
? new CapacitorBrowser()
|
||||
: new DefaultBrowser();
|
||||
};
|
||||
10
src/app/modules/auth/factories/http.factory.ts
Normal file
10
src/app/modules/auth/factories/http.factory.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Platform} from '@ionic/angular';
|
||||
import {CapacitorRequestor} from '../capacitor-requestor';
|
||||
import {NgHttpService} from '../ng-http.service';
|
||||
|
||||
export const httpFactory = (platform: Platform, httpClient: HttpClient) => {
|
||||
return platform.is('capacitor')
|
||||
? new CapacitorRequestor()
|
||||
: new NgHttpService(httpClient);
|
||||
};
|
||||
3
src/app/modules/auth/factories/index.ts
Normal file
3
src/app/modules/auth/factories/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './auth.factory';
|
||||
export * from './browser.factory';
|
||||
export * from './storage.factory';
|
||||
9
src/app/modules/auth/factories/storage.factory.ts
Normal file
9
src/app/modules/auth/factories/storage.factory.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import {Platform} from '@ionic/angular';
|
||||
import {CapacitorSecureStorage} from 'ionic-appauth/lib/capacitor';
|
||||
import {IonicStorage} from 'ionic-appauth/lib';
|
||||
|
||||
export const storageFactory = (platform: Platform) => {
|
||||
return platform.is('capacitor')
|
||||
? new CapacitorSecureStorage()
|
||||
: new IonicStorage();
|
||||
};
|
||||
Reference in New Issue
Block a user