diff --git a/dmp-frontend/package.json b/dmp-frontend/package.json index 0da7472a3..8e559d4fa 100644 --- a/dmp-frontend/package.json +++ b/dmp-frontend/package.json @@ -58,7 +58,6 @@ "@angular/platform-browser-dynamic": "^16.2.8", "@angular/router": "^16.2.8", "@types/dragula": "^3.7.2", - "@types/facebook-js-sdk": "^3.3.7", "@types/file-saver": "^2.0.5", "@types/gapi": "^0.0.45", "@types/gapi.auth2": "^0.0.58", diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index 0615a2a1c..62d9578cd 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -1,8 +1,6 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { ReloadHelperComponent } from '@app/ui/misc/reload-helper/reload-helper.component'; -import { B2AccessLoginComponent } from './ui/auth/login/b2access/b2access-login.component'; -import { Oauth2DialogModule } from './ui/misc/oauth2-dialog/oauth2-dialog.module'; import { Oauth2DialogComponent } from './ui/misc/oauth2-dialog/oauth2-dialog.component'; import { AppComponent } from './app.component'; @@ -255,12 +253,6 @@ const appRoutes: Routes = [ }, }, { path: 'logout', loadChildren: () => import('./ui/auth/logout/logout.module').then(m => m.LogoutModule) }, - { - path: 'api/oauth/authorized/b2access', - component: B2AccessLoginComponent, - data: { - }, - }, { path: 'reload', component: ReloadHelperComponent }, { path: 'oauth2', component: Oauth2DialogComponent }, { diff --git a/dmp-frontend/src/app/core/model/configuration-models/login-providers.model.ts b/dmp-frontend/src/app/core/model/configuration-models/login-providers.model.ts deleted file mode 100644 index 15474bdce..000000000 --- a/dmp-frontend/src/app/core/model/configuration-models/login-providers.model.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { LoginConfiguration } from './login-configuration.model'; - -export class LoginProviders { - - private _enabled: number[] = []; - get enabled(): number[] { - return this._enabled; - } - - private _facebookConfiguration: LoginConfiguration; - get facebookConfiguration(): LoginConfiguration { - return this._facebookConfiguration; - } - - private _googleConfiguration: LoginConfiguration; - get googleConfiguration(): LoginConfiguration { - return this._googleConfiguration; - } - - private _linkedInConfiguration: LoginConfiguration; - get linkedInConfiguration(): LoginConfiguration { - return this._linkedInConfiguration; - } - - private _twitterConfiguration: LoginConfiguration; - get twitterConfiguration(): LoginConfiguration { - return this._twitterConfiguration; - } - - private _b2accessConfiguration: LoginConfiguration; - get b2accessConfiguration(): LoginConfiguration { - return this._b2accessConfiguration; - } - - private _orcidConfiguration: LoginConfiguration; - get orcidConfiguration(): LoginConfiguration { - return this._orcidConfiguration; - } - - private _openAireConfiguration: LoginConfiguration; - get openAireConfiguration(): LoginConfiguration { - return this._openAireConfiguration; - } - - private _zenodoConfiguration: LoginConfiguration; - get zenodoConfiguration(): LoginConfiguration { - return this._zenodoConfiguration; - } - - public static parseValue(value: any): LoginProviders { - const obj: LoginProviders = new LoginProviders(); - obj._enabled = value.enabled; - obj._facebookConfiguration = value.facebookConfiguration; - obj._googleConfiguration = value.googleConfiguration; - obj._linkedInConfiguration = value.linkedInConfiguration; - obj._twitterConfiguration = value.twitterConfiguration; - obj._b2accessConfiguration = value.b2accessConfiguration; - obj._orcidConfiguration = value.orcidConfiguration; - obj._openAireConfiguration = value.openAireConfiguration; - obj._zenodoConfiguration = value.zenodoConfiguration; - return obj; - } -} diff --git a/dmp-frontend/src/app/core/services/configuration/configuration.service.ts b/dmp-frontend/src/app/core/services/configuration/configuration.service.ts index 6d7521884..55c684f56 100644 --- a/dmp-frontend/src/app/core/services/configuration/configuration.service.ts +++ b/dmp-frontend/src/app/core/services/configuration/configuration.service.ts @@ -5,10 +5,10 @@ import { BaseComponent } from '@common/base/base.component'; import { catchError, takeUntil } from 'rxjs/operators'; import { Observable, throwError } from 'rxjs'; import { HelpService } from '@app/core/model/configuration-models/help-service.model'; -import { LoginProviders } from '@app/core/model/configuration-models/login-providers.model'; import { Logging } from '@app/core/model/configuration-models/logging.model'; import { HttpClient } from '@angular/common/http'; import { KeycloakConfiguration } from '@app/core/model/configuration-models/keycloak-configuration.model'; +import { LoginConfiguration } from '@app/core/model/configuration-models/login-configuration.model'; @Injectable({ providedIn: 'root', @@ -47,11 +47,6 @@ export class ConfigurationService extends BaseComponent { return this._availableLanguages; } - private _loginProviders: LoginProviders; - get loginProviders(): LoginProviders { - return this._loginProviders; - } - private _logging: Logging; get logging(): Logging { return this._logging; @@ -142,6 +137,11 @@ export class ConfigurationService extends BaseComponent { }); } + private _zenodoConfiguration: LoginConfiguration; + get zenodoConfiguration(): LoginConfiguration { + return this._zenodoConfiguration; + } + private parseResponse(config: any) { this._server = config.Server; @@ -150,7 +150,7 @@ export class ConfigurationService extends BaseComponent { this._defaultCulture = config.defaultCulture; this._defaultLanguage = config.defaultLanguage; this._availableLanguages = config.availableLanguages; - this._loginProviders = LoginProviders.parseValue(config.loginProviders); + this._zenodoConfiguration = config.zenodoConfiguration; this._keycloak = KeycloakConfiguration.parseValue(config.keycloak); this._logging = Logging.parseValue(config.logging); this._lockInterval = config.lockInterval; diff --git a/dmp-frontend/src/app/ui/auth/login/b2access/b2access-login.component.html b/dmp-frontend/src/app/ui/auth/login/b2access/b2access-login.component.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/auth/login/b2access/b2access-login.component.ts b/dmp-frontend/src/app/ui/auth/login/b2access/b2access-login.component.ts deleted file mode 100644 index b74efb07b..000000000 --- a/dmp-frontend/src/app/ui/auth/login/b2access/b2access-login.component.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { LoginService } from '@app/ui/auth/login/utilities/login.service'; -import { BaseComponent } from '@common/base/base.component'; -import { environment } from 'environments/environment'; -import { takeUntil } from 'rxjs/operators'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; - -@Component({ - selector: 'app-b2access-login', - templateUrl: './b2access-login.component.html', -}) -export class B2AccessLoginComponent extends BaseComponent implements OnInit { - - private returnUrl: string; - - constructor( - private route: ActivatedRoute, - private authService: AuthService, - private loginService: LoginService, - private httpClient: HttpClient, - private configurationService: ConfigurationService, - private router: Router - ) { - super(); - } - - ngOnInit(): void { - this.route.queryParams - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - // const returnUrl = params['returnUrl']; - // if (returnUrl) { this.returnUrl = returnUrl; } - // if (!params['code']) { this.b2AccessGetAuthCode(); } else { this.b2AccessLogin(params['code']); } - this.router.navigate(['/oauth2'], {queryParams: params}); - }); - } - - public b2AccessGetAuthCode() { - window.location.href = this.configurationService.loginProviders.b2accessConfiguration.oauthUrl - + '?response_type=code&client_id=' + this.configurationService.loginProviders.b2accessConfiguration.clientId - + '&redirect_uri=' + this.configurationService.loginProviders.b2accessConfiguration.redirectUri - + '&state=' + this.configurationService.loginProviders.b2accessConfiguration.state - + '&scope=USER_PROFILE'; - } - - public b2AccessLogin(code: String) { - // let headers = new HttpHeaders(); - // headers = headers.set('Content-Type', 'application/json'); - // headers = headers.set('Accept', 'application/json'); - // this.httpClient.post(this.configurationService.server + 'auth/b2AccessRequestToken', { code: code }, { headers: headers }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe((data: any) => { - // this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.B2Access, data: null }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ); - // }); - } -} diff --git a/dmp-frontend/src/app/ui/auth/login/configurable-login/configurable-login.component.html b/dmp-frontend/src/app/ui/auth/login/configurable-login/configurable-login.component.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/auth/login/configurable-login/configurable-login.component.ts b/dmp-frontend/src/app/ui/auth/login/configurable-login/configurable-login.component.ts deleted file mode 100644 index fb0a756b0..000000000 --- a/dmp-frontend/src/app/ui/auth/login/configurable-login/configurable-login.component.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit } from "@angular/core"; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { ConfigurableProvider } from '@app/core/model/configurable-provider/configurableProvider'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurableProvidersService } from '@app/ui/auth/login/utilities/configurableProviders.service'; -import { LoginService } from '@app/ui/auth/login/utilities/login.service'; -import { BaseComponent } from '@common/base/base.component'; -import { environment } from 'environments/environment'; -import * as pk from 'pako'; -import { takeUntil } from 'rxjs/operators'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { SamlLoginService } from '@app/core/services/saml-login.service'; -import { Oauth2ConfigurableProvider } from '@app/core/model/configurable-provider/oauth2ConfigurableProvider'; -import { Saml2ConfigurableProvider } from '@app/core/model/configurable-provider/saml2ConfigurableProvider'; -import { ConfigurableProviderType } from '@app/core/common/enum/configurable-provider-type'; - -@Component({ - selector: 'app-configurable-login', - templateUrl: './configurable-login.component.html', -}) -export class ConfigurableLoginComponent extends BaseComponent implements OnInit { - private returnUrl: string; - - // private configurableLoginId: string; - // private clientId: string; - // private oauthUrl: string; - // private redirectUri: string; - // private state: string; - // @Input() scope: string; - - private provider: ConfigurableProvider; - private providerId: string; - - constructor( - private route: ActivatedRoute, - private loginService: LoginService, - private authService: AuthService, - private router: Router, - private httpClient: HttpClient, - private providers: ConfigurableProvidersService, - private configurationService: ConfigurationService, - private samlLoginService: SamlLoginService - ) { - super(); - } - - ngOnInit(): void { - const params = this.route.snapshot.params; - this.providerId = params['id']; - if (this.providers.providers === undefined) { - // this.authService.getConfigurableProviders() - // .pipe(takeUntil(this._destroyed)) - // .subscribe((data) => { - // this.providers.providers = data; - // this.provider = this.providers.providers.find(item => item.configurableLoginId == this.providerId) - // this.route.queryParams - // .pipe(takeUntil(this._destroyed)) - // .subscribe((params: Params) => { - // const returnUrlFromParams = params['returnUrl']; - // if (returnUrlFromParams) { this.returnUrl = returnUrlFromParams; } - // if (!params['code']) { this.configurableAuthorize(); } else { this.configurableLoginUser(params['code'], params['state']) } - // }) - // }); - } else { - this.provider = this.providers.providers.find(item => item.configurableLoginId == this.providerId) - this.route.queryParams - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - const returnUrlFromParams = params['returnUrl']; - if (returnUrlFromParams) { this.returnUrl = returnUrlFromParams; } - if (!params['code']) { this.configurableAuthorize(); } else { this.configurableLoginUser(params['code'], params['state']) } - }) - } - } - - public configurableAuthorize() { - if(this.provider.type === ConfigurableProviderType.Oauth2){ - let provider = this.provider as Oauth2ConfigurableProvider; - let authUrl = provider.oauthUrl - + '?response_type=code&client_id=' + provider.clientId - + '&redirect_uri=' + provider.redirect_uri - + '&scope=' + provider.scope; - if (provider.state.length > 0) authUrl = authUrl + '&state=' + provider.state - window.location.href = authUrl; - } - else if(this.provider.type === ConfigurableProviderType.Saml2){ - let provider = this.provider as Saml2ConfigurableProvider; - this.samlLoginService.getAuthnRequest(provider.configurableLoginId).pipe(takeUntil(this._destroyed)) - .subscribe( - authenticationRequest => { - const uint = new Uint8Array(authenticationRequest.authnRequestXml.length); - for (let i = 0, j = authenticationRequest.authnRequestXml.length; i < j; ++i) { - uint[i] = authenticationRequest.authnRequestXml.charCodeAt(i); - } - const base64String = btoa(pk.deflateRaw(uint, { to: 'string' })); - const url = provider.idpUrl + '?SAMLRequest=' + encodeURIComponent(base64String) + '&RelayState=' + encodeURIComponent(authenticationRequest.relayState) + '&SigAlg=' + encodeURIComponent(authenticationRequest.algorithm) + '&Signature=' + encodeURIComponent(authenticationRequest.signature); - window.location.href = url; - } - ); - } - } - - public configurableLoginUser(code: string, state: string) { - // if (state !== (this.provider).state) { - // this.router.navigate(['/login']) - // } - // this.httpClient.post(this.configurationService.server + 'auth/configurableProviderRequestToken', { code: code, provider: AuthProvider.Configurable, configurableLoginId: this.providerId }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe((data: any) => { - // this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.Configurable, data: { configurableLoginId: this.provider.configurableLoginId } }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ) - // }) - } -} diff --git a/dmp-frontend/src/app/ui/auth/login/linkedin-login/linkedin-login.component.html b/dmp-frontend/src/app/ui/auth/login/linkedin-login/linkedin-login.component.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/auth/login/linkedin-login/linkedin-login.component.ts b/dmp-frontend/src/app/ui/auth/login/linkedin-login/linkedin-login.component.ts deleted file mode 100644 index 1d300382c..000000000 --- a/dmp-frontend/src/app/ui/auth/login/linkedin-login/linkedin-login.component.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { HttpClient } from "@angular/common/http"; -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { LoginService } from '@app/ui/auth/login/utilities/login.service'; -import { BaseComponent } from '@common/base/base.component'; -import { environment } from 'environments/environment'; -import { takeUntil } from 'rxjs/operators'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; - -@Component({ - selector: 'app-linkedin-login', - templateUrl: './linkedin-login.component.html', -}) -export class LinkedInLoginComponent extends BaseComponent implements OnInit { - - private returnUrl: string; - - constructor( - private route: ActivatedRoute, - private loginService: LoginService, - private authService: AuthService, - private router: Router, - private httpClient: HttpClient, - private configurationService: ConfigurationService - ) { - super(); - } - - ngOnInit(): void { - this.route.queryParams - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - // const returnUrl = params['returnUrl']; - // if (returnUrl) { this.returnUrl = returnUrl; } - // if (!params['code']) { this.linkedinAuthorize(); } else { this.linkedInLoginUser(params['code'], params['state']); } - this.router.navigate(['/oauth2'], {queryParams: params}); - }); - } - - public linkedinAuthorize() { - window.location.href = this.configurationService.loginProviders.linkedInConfiguration.oauthUrl - + '?response_type=code&client_id=' + this.configurationService.loginProviders.linkedInConfiguration.clientId - + '&redirect_uri=' + this.configurationService.loginProviders.linkedInConfiguration.redirectUri - + '&state=' + this.configurationService.loginProviders.linkedInConfiguration.state - + '&scope=r_emailaddress'; - } - - public linkedInLoginUser(code: string, state: string) { - // if (state !== this.configurationService.loginProviders.linkedInConfiguration.state) { - // this.router.navigate(['/login']); - // } - // this.httpClient.post(this.configurationService.server + 'auth/linkedInRequestToken', { code: code, provider: AuthProvider.LinkedIn }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe((data: any) => { - // this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.LinkedIn, data: null }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ); - // }); - } -} diff --git a/dmp-frontend/src/app/ui/auth/login/login.component.html b/dmp-frontend/src/app/ui/auth/login/login.component.html index bfb4b9f13..cdaf7d3d6 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.component.html +++ b/dmp-frontend/src/app/ui/auth/login/login.component.html @@ -1,81 +1,5 @@
- -
diff --git a/dmp-frontend/src/app/ui/auth/login/login.component.ts b/dmp-frontend/src/app/ui/auth/login/login.component.ts index 9982d5db7..2dc737d76 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.component.ts @@ -1,23 +1,6 @@ -import { AfterViewInit, Component, Input, OnInit } from '@angular/core'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { ConfigurableProvider } from '@app/core/model/configurable-provider/configurableProvider'; +import { Component, Input, OnInit } from '@angular/core'; import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurableProvidersService } from '@app/ui/auth/login/utilities/configurableProviders.service'; -import { LoginService } from '@app/ui/auth/login/utilities/login.service'; import { BaseComponent } from '@common/base/base.component'; -import { environment } from 'environments/environment'; -import { takeUntil } from 'rxjs/operators'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { MergeLoginService } from './utilities/merge-login.service'; -import { Oauth2DialogService } from '@app/ui/misc/oauth2-dialog/service/oauth2-dialog.service'; -import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { BehaviorSubject } from 'rxjs'; -import { UntypedFormControl } from '@angular/forms'; -import { OrcidUser } from '@app/core/model/orcid/orcidUser'; -import { ZenodoToken } from '@app/core/model/zenodo/zenodo-token.model'; -import { LoginInfo } from '@app/core/model/auth/login-info'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; /// /// @@ -30,406 +13,21 @@ declare const FB: any; templateUrl: './login.component.html', styleUrls: ['./login.component.scss'] }) -export class LoginComponent extends BaseComponent implements OnInit, AfterViewInit { +export class LoginComponent extends BaseComponent implements OnInit { @Input() redirect: boolean = true; @Input() mergeUsers: boolean; public auth2: any; private returnUrl: string; - private twitterUrl = new BehaviorSubject(undefined); - private emailFormControl = new UntypedFormControl(''); - private orcidUser: OrcidUser; - private zenodoToken: ZenodoToken; - private accessToken: string; - private oauthLock: boolean; //public cofigurableProviders: ConfigurableProvider[]; constructor( - private router: Router, - private route: ActivatedRoute, - private loginService: LoginService, private authService: AuthService, - public configurableProviderService: ConfigurableProvidersService, - private configurationService: ConfigurationService, - private mergeLoginService: MergeLoginService, - private oauth2DialogService: Oauth2DialogService, - private httpClient: HttpClient, - private matomoService: MatomoService, ) { super(); } ngOnInit(): void { const returnUrL = this.returnUrl; this.authService.authenticate(returnUrL ? returnUrL : "/"); - // if(this.authService.currentAccountIsAuthenticated() && (this.redirect == true)){ - // this.router.navigate(['home']); - // } - // this.matomoService.trackPageView('loginPage'); - // this.route.queryParams - // .pipe(takeUntil(this._destroyed)) - // .subscribe((params: Params) => { - // const returnUrl = params['returnUrl']; - // if (returnUrl) { this.returnUrl = returnUrl; } - // }); - // this.authService.getConfigurableProviders() - // .pipe(takeUntil(this._destroyed)) - // .subscribe((data: any) => { - // this.configurableProviderService.providers = data; - // }) - } - - ngAfterViewInit() { - this.initProviders(); - } - - public linkedInLogin() { - //this.router.navigate(['/login/linkedin']); - this.oauth2DialogService.login(this.getLinkedInUrl()).pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result !== undefined) { - if (!this.oauthLock) { - this.linkedInLoginUser(result.oauthCode, result.oauthState); - this.oauthLock = true; - } - } else { - this.oauthLock = false; - } - }); - } - - public twitterLogin() { - // this.router.navigate(['/login/twitter']); - this.twitterUrl.asObservable().pipe(takeUntil(this._destroyed)).subscribe(url => { - if (url !== undefined) { - this.oauth2DialogService.login(url).pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result !== undefined) { - if (!this.oauthLock) { - this.twitterLoginUser(result.oauthToken, result.oauthVerifier); - this.oauthLock = true; - } - } else { - this.oauthLock = false; - } - }); - } - }); - this.twitterAuthorize(); - } - - public b2AccessLogin() { - //this.router.navigate(['/login/external/b2access'], {queryParams: {returnUrl: this.returnUrl, mergeUsers: this.mergeUsers}}); - this.oauth2DialogService.login(this.getB2AccessUrl()).pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result !== undefined) { - if (!this.oauthLock) { - this.b2AccessLoginUser(result.oauthCode); - this.oauthLock = true; - } - } else { - this.oauthLock = false; - } - }); - } - - public orcidLogin() { - //this.router.navigate(['/login/external/orcid']); - this.oauth2DialogService.login(this.getORCIDUrl()).pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result !== undefined) { - if (!this.oauthLock) { - this.orcidLoginUser(result.oauthCode); - this.oauthLock = true; - } - } else { - this.oauthLock = false; - } - }); - } - - public openaireLogin() { - //this.router.navigate(['/login/openaire']); - this.oauth2DialogService.login(this.getOpenAireUrl()).pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result !== undefined) { - if (!this.oauthLock) { - this.openaireLoginUser(result.oauthCode, result.oauthState); - this.oauthLock = true; - } - } else { - this.oauthLock = false; - } - }); - } - - public configurableLogin(provider: ConfigurableProvider) { - this.router.navigate(['/login/configurable/' + provider.configurableLoginId]) - } - - public zenodoLogin() { - //this.router.navigate(['/login/external/zenodo']); - this.oauth2DialogService.login(this.getZenodoUrl()).pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result !== undefined) { - if (!this.oauthLock) { - this.zenodoLoginUser(result.oauthCode); - this.oauthLock = true; - } - } else { - this.oauthLock = false; - } - }); - } - - public hasFacebookOauth(): boolean { - return this.hasProvider(AuthProvider.Facebook); - } - - public hasLinkedInOauth(): boolean { - return this.hasProvider(AuthProvider.LinkedIn); - } - - public hasTwitterOauth(): boolean { - return this.hasProvider(AuthProvider.Twitter); - } - - public hasGoogleOauth(): boolean { - return this.hasProvider(AuthProvider.Google); - } - - public hasB2AccessOauth(): boolean { - return this.hasProvider(AuthProvider.B2Access); - } - - public hasOrcidOauth(): boolean { - return this.hasProvider(AuthProvider.ORCID); - } - - public hasOpenAireOauth(): boolean { - return this.hasProvider(AuthProvider.OpenAire); - } - - public hasZenodoOauth(): boolean { - return this.hasProvider(AuthProvider.Zenodo); - } - - public initProviders() { - if (this.hasProvider(AuthProvider.Google)) { this.initializeGoogleOauth(); } - if (this.hasProvider(AuthProvider.Facebook)) { this.initializeFacebookOauth(); } - } - - public hasProvider(provider: AuthProvider) { - for (let i = 0; i < this.configurationService.loginProviders.enabled.length; i++) { - if (provider === this.configurationService.loginProviders.enabled[i]) { return this.isProviderProperlyConfigured(provider); } - } - return false; - } - - private isProviderProperlyConfigured(provider: AuthProvider) { - switch (provider) { - case AuthProvider.Facebook: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.facebookConfiguration); - case AuthProvider.Google: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.googleConfiguration); - case AuthProvider.LinkedIn: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.linkedInConfiguration); - case AuthProvider.Twitter: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.twitterConfiguration); - case AuthProvider.B2Access: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.b2accessConfiguration); - case AuthProvider.ORCID: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.orcidConfiguration); - case AuthProvider.OpenAire: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.openAireConfiguration); - case AuthProvider.Zenodo: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.zenodoConfiguration); - default: throw new Error('Unsupported Provider Type'); - } - } - - private hasAllRequiredFieldsConfigured(configuration: any) { - if (configuration != null && configuration.clientId != null) { return true; } - return false; - } - - /* - * GOOGLE SIGN IN - */ - private initializeGoogleOauth(): void { - gapi.load('auth2', () => { - this.auth2 = gapi.auth2.init({ - client_id: this.configurationService.loginProviders.googleConfiguration.clientId, - scope: 'profile email' - }); - this.attachGoogleSignΙn(document.getElementById('googleSignInButton')); - }); - } - - public attachGoogleSignΙn(element) { - if (!element) { return; } - this.auth2.attachClickHandler(element, {}, - (googleUser) => { - const id_token = googleUser.getAuthResponse().id_token; - if (id_token) { - this.authLogin({ ticket: id_token, provider: AuthProvider.Google }); - } - }, (error) => { - }); - } - - /* - * FACEBOOK SIGN IN - */ - private initializeFacebookOauth(): void { - FB.init({ - appId: this.configurationService.loginProviders.facebookConfiguration.clientId, - cookie: false, - xfbml: true, - version: 'v2.8' - }); - } - - public facebookLogin() { - FB.login((response: any) => { - if (response.status === 'connected' || 'not_authorized') { - this.authLogin({ ticket: response.authResponse.accessToken, provider: AuthProvider.Facebook }); - } - }, { scope: 'email' }); - } - - public hasConfigurableProviders(): boolean { - return !(this.configurableProviderService.providers == undefined) && this.configurableProviderService.providers.length > 0 - } - - private getLinkedInUrl() { - return this.configurationService.loginProviders.linkedInConfiguration.oauthUrl - + '?response_type=code&client_id=' + this.configurationService.loginProviders.linkedInConfiguration.clientId - + '&redirect_uri=' + this.configurationService.loginProviders.linkedInConfiguration.redirectUri - + '&state=' + this.configurationService.loginProviders.linkedInConfiguration.state - + '&scope=r_emailaddress'; - } - - public linkedInLoginUser(code: string, state: string) { - if (state !== this.configurationService.loginProviders.linkedInConfiguration.state) { - this.router.navigate(['/login']); - } - this.httpClient.post(this.configurationService.server + 'auth/linkedInRequestToken', { code: code, provider: AuthProvider.LinkedIn }) - .pipe(takeUntil(this._destroyed)) - .subscribe((data: any) => { - this.authLogin({ ticket: data.payload.accessToken, provider: AuthProvider.LinkedIn, data: null }); - }); - } - - public twitterAuthorize() { - let headers = new HttpHeaders(); - headers = headers.set('Content-Type', 'application/json'); - headers = headers.set('Accept', 'application/json'); - this.httpClient.get(this.configurationService.server + 'auth/twitterRequestToken', { headers: headers }) - .pipe(takeUntil(this._destroyed)) - .subscribe((data: any) => { - this.twitterUrl.next(this.configurationService.loginProviders.twitterConfiguration.oauthUrl + '?oauth_token=' + data.payload.value); - }); - } - - public twitterLoginUser(token: string, verifier: string) { - const data = { - email: this.emailFormControl.value, verifier: verifier - }; - this.authLogin({ ticket: token, provider: AuthProvider.Twitter, data: data }); - } - - private getB2AccessUrl() { - return this.configurationService.loginProviders.b2accessConfiguration.oauthUrl - + '?response_type=code&client_id=' + this.configurationService.loginProviders.b2accessConfiguration.clientId - + '&redirect_uri=' + this.configurationService.loginProviders.b2accessConfiguration.redirectUri - + '&state=' + this.configurationService.loginProviders.b2accessConfiguration.state - + '&scope=USER_PROFILE'; - } - - public b2AccessLoginUser(code: String) { - let headers = new HttpHeaders(); - headers = headers.set('Content-Type', 'application/json'); - headers = headers.set('Accept', 'application/json'); - this.httpClient.post(this.configurationService.server + 'auth/b2AccessRequestToken', { code: code }, { headers: headers }) - .pipe(takeUntil(this._destroyed)) - .subscribe((data: any) => { - this.authLogin({ ticket: data.payload.accessToken, provider: AuthProvider.B2Access, data: null }); - }); - } - - private getORCIDUrl() { - return this.configurationService.loginProviders.orcidConfiguration.oauthUrl - + '?client_id=' - + this.configurationService.loginProviders.orcidConfiguration.clientId - + '&response_type=code&scope=/authenticate&redirect_uri=' - + this.configurationService.loginProviders.orcidConfiguration.redirectUri; - } - - public orcidLoginUser(code: string) { - let headers = new HttpHeaders(); - headers = headers.set('Content-Type', 'application/json'); - headers = headers.set('Accept', 'application/json'); - this.httpClient.post(this.configurationService.server + 'auth/orcidRequestToken', { code: code }, { headers: headers }) - .pipe(takeUntil(this._destroyed)) - .subscribe((responseData: any) => { - this.orcidUser = new OrcidUser(); - this.orcidUser.orcidId = responseData.payload.orcidId - this.orcidUser.name = responseData.payload.name - this.accessToken = responseData.payload.accessToken; - this.authLogin({ ticket: this.accessToken, provider: AuthProvider.ORCID, data: this.orcidUser }); - }); - } - - private getOpenAireUrl() { - return this.configurationService.loginProviders.openAireConfiguration.oauthUrl - + '?response_type=code&client_id=' + this.configurationService.loginProviders.openAireConfiguration.clientId - + '&redirect_uri=' + this.configurationService.loginProviders.openAireConfiguration.redirectUri - + '&state=' + this.configurationService.loginProviders.openAireConfiguration.state - + '&scope=openid profile email'; - } - - public openaireLoginUser(code: string, state: string) { - if (state !== this.configurationService.loginProviders.openAireConfiguration.state) { - this.router.navigate(['/login']) - } - this.httpClient.post(this.configurationService.server + 'auth/openAireRequestToken', { code: code, provider: AuthProvider.OpenAire }) - .pipe(takeUntil(this._destroyed)) - .subscribe((data: any) => { - this.authLogin({ ticket: data.payload.accessToken, provider: AuthProvider.OpenAire, data: null }); - }); - } - - private getZenodoUrl() { - return this.configurationService.loginProviders.zenodoConfiguration.oauthUrl - + '?client_id=' - + this.configurationService.loginProviders.zenodoConfiguration.clientId - + '&response_type=code&scope=deposit:write+deposit:actions+user:email&state=astate&redirect_uri=' - + this.configurationService.loginProviders.zenodoConfiguration.redirectUri; - } - - public zenodoLoginUser(code: string) { - let headers = new HttpHeaders(); - headers = headers.set('Content-Type', 'application/json'); - headers = headers.set('Accept', 'application/json'); - this.httpClient.post(this.configurationService.server + 'auth/zenodoRequestToken', { code: code }, { headers: headers }) - .pipe(takeUntil(this._destroyed)) - .subscribe((responseData: any) => { - this.zenodoToken = new ZenodoToken(); - this.zenodoToken.userId = responseData.payload.userId; - this.zenodoToken.expiresIn = responseData.payload.expiresIn; - this.accessToken = this.zenodoToken.accessToken = responseData.payload.accessToken; - this.zenodoToken.email = responseData.payload.email; - this.zenodoToken.refreshToken = responseData.payload.refreshToken; - this.authLogin({ ticket: this.accessToken, provider: AuthProvider.Zenodo, data: this.zenodoToken }); - }); - } - - private authLogin(loginInfo: LoginInfo) { - // if (this.mergeUsers) { - // this.authService.mergeLogin(loginInfo) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.mergeLoginService.setRequest({email: res.payload.email, userId: res.payload.id, provider: loginInfo.provider}) - // ); - // } else { - // this.authService.login(loginInfo) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ); - // } } } diff --git a/dmp-frontend/src/app/ui/auth/login/login.module.ts b/dmp-frontend/src/app/ui/auth/login/login.module.ts index 8d5b84740..9742360ef 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.module.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.module.ts @@ -1,23 +1,14 @@ import { NgModule } from '@angular/core'; -import { B2AccessLoginComponent } from '@app/ui/auth/login/b2access/b2access-login.component'; -import { ConfigurableLoginComponent } from '@app/ui/auth/login/configurable-login/configurable-login.component'; import { EmailConfirmation } from '@app/ui/auth/login/email-confirmation/email-confirmation.component'; -import { LinkedInLoginComponent } from '@app/ui/auth/login/linkedin-login/linkedin-login.component'; import { LoginComponent } from '@app/ui/auth/login/login.component'; import { LoginRoutingModule } from '@app/ui/auth/login/login.routing'; -import { OpenAireLoginComponent } from '@app/ui/auth/login/openaire-login/openaire-login.component'; -import { OrcidLoginComponent } from '@app/ui/auth/login/orcid-login/orcid-login.component'; -import { TwitterLoginComponent } from '@app/ui/auth/login/twitter-login/twitter-login.component'; -import { ConfigurableProvidersService } from '@app/ui/auth/login/utilities/configurableProviders.service'; import { LoginService } from '@app/ui/auth/login/utilities/login.service'; import { Oauth2DialogModule } from '@app/ui/misc/oauth2-dialog/oauth2-dialog.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; import { MergeEmailConfirmation } from './merge-email-confirmation/merge-email-confirmation.component'; import { MergeLoginService } from './utilities/merge-login.service'; -import { ZenodoLoginComponent } from './zenodo-login/zenodo-login.component'; import { SamlLoginService } from '@app/core/services/saml-login.service'; -import { SamlResponseLoginComponent } from './saml/saml-login-response/saml-login-response.component'; import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-email-confirmation.component'; @NgModule({ @@ -29,21 +20,13 @@ import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-emai ], declarations: [ LoginComponent, - LinkedInLoginComponent, - TwitterLoginComponent, - B2AccessLoginComponent, - OrcidLoginComponent, EmailConfirmation, - OpenAireLoginComponent, - ConfigurableLoginComponent, - ZenodoLoginComponent, MergeEmailConfirmation, UnlinkEmailConfirmation, - SamlResponseLoginComponent ], exports: [ LoginComponent ], - providers: [LoginService, MergeLoginService, ConfigurableProvidersService, SamlLoginService] + providers: [LoginService, MergeLoginService, SamlLoginService] }) export class LoginModule { } diff --git a/dmp-frontend/src/app/ui/auth/login/login.routing.ts b/dmp-frontend/src/app/ui/auth/login/login.routing.ts index 2ba809b6b..48e43575e 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.routing.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.routing.ts @@ -1,33 +1,16 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { B2AccessLoginComponent } from './b2access/b2access-login.component'; import { EmailConfirmation } from './email-confirmation/email-confirmation.component'; -import { LinkedInLoginComponent } from './linkedin-login/linkedin-login.component'; import { LoginComponent } from './login.component'; -import { OrcidLoginComponent } from './orcid-login/orcid-login.component'; -import { TwitterLoginComponent } from './twitter-login/twitter-login.component'; -import { OpenAireLoginComponent } from "./openaire-login/openaire-login.component"; -import { ConfigurableLoginComponent } from "./configurable-login/configurable-login.component"; -import { ZenodoLoginComponent } from './zenodo-login/zenodo-login.component'; -import { Oauth2DialogComponent } from '@app/ui/misc/oauth2-dialog/oauth2-dialog.component'; import { MergeEmailConfirmation } from './merge-email-confirmation/merge-email-confirmation.component'; -import { SamlResponseLoginComponent } from './saml/saml-login-response/saml-login-response.component'; import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-email-confirmation.component'; const routes: Routes = [ { path: '', component: LoginComponent }, - { path: 'linkedin', component: Oauth2DialogComponent }, - { path: 'twitter', component: Oauth2DialogComponent }, - { path: 'external/orcid', component: Oauth2DialogComponent }, - { path: 'external/b2access', component: Oauth2DialogComponent }, { path: 'confirmation/:token', component: EmailConfirmation }, { path: 'merge/confirmation/:token', component: MergeEmailConfirmation }, { path: 'unlink/confirmation/:token', component: UnlinkEmailConfirmation }, - { path: 'confirmation', component: EmailConfirmation }, - { path: 'openaire', component: Oauth2DialogComponent}, - { path: 'configurable/:id', component: ConfigurableLoginComponent}, - { path: 'external/zenodo', component: Oauth2DialogComponent }, - { path: 'external/saml', component: SamlResponseLoginComponent } + { path: 'confirmation', component: EmailConfirmation } ]; @NgModule({ diff --git a/dmp-frontend/src/app/ui/auth/login/openaire-login/openaire-login.component.html b/dmp-frontend/src/app/ui/auth/login/openaire-login/openaire-login.component.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/auth/login/openaire-login/openaire-login.component.ts b/dmp-frontend/src/app/ui/auth/login/openaire-login/openaire-login.component.ts deleted file mode 100644 index 566efe8a0..000000000 --- a/dmp-frontend/src/app/ui/auth/login/openaire-login/openaire-login.component.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit } from "@angular/core"; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { LoginService } from '@app/ui/auth/login/utilities/login.service'; -import { BaseComponent } from '@common/base/base.component'; -import { environment } from 'environments/environment'; -import { takeUntil } from 'rxjs/operators'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; - -@Component({ - selector: 'app-openaire-login', - templateUrl: './openaire-login.component.html', -}) -export class OpenAireLoginComponent extends BaseComponent implements OnInit { - private returnUrl: string; - - constructor( - private route: ActivatedRoute, - private loginService: LoginService, - private authService: AuthService, - private router: Router, - private httpClient: HttpClient, - private configurationService: ConfigurationService - ) { - super(); - } - - ngOnInit(): void { - this.route.queryParams - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - // const returnUrlFromParams = params['returnUrl']; - // if (returnUrlFromParams) { this.returnUrl = returnUrlFromParams; } - // if (!params['code']) { this.openaireAuthorize(); } else { this.openaireLoginUser(params['code'], params['state']) } - this.router.navigate(['/oauth2'], {queryParams: params}); - }) - } - - public openaireAuthorize() { - window.location.href = this.configurationService.loginProviders.openAireConfiguration.oauthUrl - + '?response_type=code&client_id=' + this.configurationService.loginProviders.openAireConfiguration.clientId - + '&redirect_uri=' + this.configurationService.loginProviders.openAireConfiguration.redirectUri - + '&state=' + this.configurationService.loginProviders.openAireConfiguration.state - + '&scope=openid profile email'; - } - - public openaireLoginUser(code: string, state: string) { - // if (state !== this.configurationService.loginProviders.openAireConfiguration.state) { - // this.router.navigate(['/login']) - // } - // this.httpClient.post(this.configurationService.server + 'auth/openAireRequestToken', { code: code, provider: AuthProvider.OpenAire }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe((data: any) => { - // this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.OpenAire, data: null }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ); - // }); - } -} diff --git a/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.html b/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.scss b/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.ts b/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.ts deleted file mode 100644 index d712cb0ab..000000000 --- a/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { Component, OnInit } from '@angular/core'; -import { UntypedFormControl } from '@angular/forms'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { OrcidUser } from '@app/core/model/orcid/orcidUser'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { LoginService } from '@app/ui/auth/login/utilities/login.service'; -import { BaseComponent } from '@common/base/base.component'; -import { environment } from 'environments/environment'; -import { takeUntil } from 'rxjs/operators'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; - -@Component({ - selector: 'app-orcid-login', - templateUrl: './orcid-login.component.html', - styleUrls: ['./orcid-login.component.scss'] -}) -export class OrcidLoginComponent extends BaseComponent implements OnInit { - - private returnUrl: string; - private orcidUser: OrcidUser - private accessToken: string; - private emailFormControl = new UntypedFormControl(''); - - constructor( - private route: ActivatedRoute, - private authService: AuthService, - private loginService: LoginService, - private httpClient: HttpClient, - private configurationService: ConfigurationService, - private router: Router - ) { - super(); - this.orcidUser = new OrcidUser; - } - - ngOnInit(): void { - this.route.queryParams - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - // const returnUrl = params['returnUrl']; - // if (returnUrl) { this.returnUrl = returnUrl; } - // if (!params['code']) { this.orcidAccessGetAuthCode(); } else { this.orcidLogin(params['code']); } - this.router.navigate(['/oauth2'], {queryParams: params}); - }); - } - - public orcidAccessGetAuthCode() { - window.location.href = this.configurationService.loginProviders.orcidConfiguration.oauthUrl - + '?client_id=' - + this.configurationService.loginProviders.orcidConfiguration.clientId - + '&response_type=code&scope=/authenticate&redirect_uri=' - + this.configurationService.loginProviders.orcidConfiguration.redirectUri; - } - - public orcidLogin(code: string) { - // let headers = new HttpHeaders(); - // headers = headers.set('Content-Type', 'application/json'); - // headers = headers.set('Accept', 'application/json'); - // this.httpClient.post(this.configurationService.server + 'auth/orcidRequestToken', { code: code }, { headers: headers }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe((responseData: any) => { - // this.orcidUser.orcidId = responseData.payload.orcidId - // this.orcidUser.name = responseData.payload.name - // this.accessToken = responseData.payload.accessToken; - // this.authService.login({ ticket: this.accessToken, provider: AuthProvider.ORCID, data: this.orcidUser }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ); - // }); - } - - public login() { - // this.orcidUser.email = this.emailFormControl.value; - // this.authService.login({ ticket: this.accessToken, provider: AuthProvider.ORCID, data: this.orcidUser }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ); - } -} diff --git a/dmp-frontend/src/app/ui/auth/login/saml/saml-login-response/saml-login-response.component.ts b/dmp-frontend/src/app/ui/auth/login/saml/saml-login-response/saml-login-response.component.ts deleted file mode 100644 index e2e1f71c1..000000000 --- a/dmp-frontend/src/app/ui/auth/login/saml/saml-login-response/saml-login-response.component.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { HttpErrorResponse } from '@angular/common/http'; -import { Component, NgZone, OnInit } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { BaseComponent } from '@common/base/base.component'; -import { LoggingService } from '@app/core/services/logging/logging-service'; -import { SamlLoginService } from '@app/core/services/saml-login.service'; -import { TranslateService } from '@ngx-translate/core'; -import { takeUntil } from 'rxjs/operators'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; - -@Component({ - template: '' -}) -export class SamlResponseLoginComponent extends BaseComponent implements OnInit { - - constructor( - private route: ActivatedRoute, - private samlLoginService: SamlLoginService, - private router: Router, - private uiNotificationService: UiNotificationService, - private loggingService: LoggingService, - private zone: NgZone, - private language: TranslateService, - private authService: AuthService, - ) { super(); } - - ngOnInit() { - // this.route.queryParams - // .pipe(takeUntil(this._destroyed)) - // .subscribe(routeParams => { - // let samlResponse = null; - // if (routeParams.SAMLart) { - // samlResponse = routeParams.SAMLart; - // } else if (routeParams.SAMLResponse) { - // samlResponse = routeParams.SAMLResponse; - // } - // else if(routeParams.token){ - // this.authService.getUserFromToken(routeParams.token).pipe(takeUntil(this._destroyed)) - // .subscribe((result) => this.onAuthenticateSuccess(), (error) => this.onAuthenticateError(error)); - // return; - // } - - // if (samlResponse == null) this.router.navigate(['/login']); - - // const spId = this.samlLoginService.resolveSpId(routeParams.RelayState); - // const configurableLoginId = this.samlLoginService.resolveConfigurableLoginId(routeParams.RelayState); - - // this.authService.login({ ticket: samlResponse, provider: AuthProvider.Configurable, data: { configurableLoginId: configurableLoginId } }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe((result) => this.onAuthenticateSuccess(), (error) => this.onAuthenticateError(error)); - - // }); - } - - onAuthenticateSuccess(): void { - this.loggingService.info('Successful Login'); - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-LOGIN'), SnackBarNotificationLevel.Success); - this.zone.run(() => this.router.navigate(['/'])); - } - - onAuthenticateError(errorResponse: HttpErrorResponse) { - this.uiNotificationService.snackBarNotification(errorResponse.error.message, SnackBarNotificationLevel.Warning); - this.zone.run(() => this.router.navigate(['/'])); - } - -} diff --git a/dmp-frontend/src/app/ui/auth/login/twitter-login/twitter-login.component.html b/dmp-frontend/src/app/ui/auth/login/twitter-login/twitter-login.component.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/auth/login/twitter-login/twitter-login.component.ts b/dmp-frontend/src/app/ui/auth/login/twitter-login/twitter-login.component.ts deleted file mode 100644 index c745d670b..000000000 --- a/dmp-frontend/src/app/ui/auth/login/twitter-login/twitter-login.component.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { BaseHttpService } from '@app/core/services/http/base-http.service'; -import { LoginService } from '@app/ui/auth/login/utilities/login.service'; -import { BaseComponent } from '@common/base/base.component'; -import { environment } from 'environments/environment'; -import { takeUntil } from 'rxjs/operators'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { UntypedFormControl } from '@angular/forms'; -import { stringify } from 'querystring'; - -@Component({ - selector: 'app-twitter-login', - templateUrl: './twitter-login.component.html', -}) -export class TwitterLoginComponent extends BaseComponent implements OnInit { - - private returnUrl: string; - private emailFormControl = new UntypedFormControl(''); - - constructor( - private route: ActivatedRoute, - private authService: AuthService, - private httpClient: BaseHttpService, - private loginService: LoginService, - private configurationService: ConfigurationService, - private router: Router - ) { - super(); - } - - ngOnInit(): void { - this.route.queryParams - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - // const returnUrl = params['returnUrl']; - // if (returnUrl) { this.returnUrl = returnUrl; } - // if (!params['oauth_token'] && !params['oauth_verifier']) { this.twitterAuthorize(); } else { this.twitterLogin(params['oauth_token'], params['oauth_verifier']); } - this.router.navigate(['/oauth2'], {queryParams: params}); - }); - } - - public twitterAuthorize() { - let headers = new HttpHeaders(); - headers = headers.set('Content-Type', 'application/json'); - headers = headers.set('Accept', 'application/json'); - this.httpClient.get(this.configurationService.server + 'auth/twitterRequestToken', { headers: headers }) - .pipe(takeUntil(this._destroyed)) - .subscribe((data: any) => { - window.location.href = this.configurationService.loginProviders.twitterConfiguration.oauthUrl + '?oauth_token=' + data.payload.value; - }); - } - - public twitterLogin(token: string, verifier: string) { - // const data = { - // email: this.emailFormControl.value, verifier: verifier - // }; - // this.authService.login({ ticket: token, provider: AuthProvider.Twitter, data: data }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ); - } -} diff --git a/dmp-frontend/src/app/ui/auth/login/utilities/configurableProviders.service.ts b/dmp-frontend/src/app/ui/auth/login/utilities/configurableProviders.service.ts deleted file mode 100644 index 0c269b45d..000000000 --- a/dmp-frontend/src/app/ui/auth/login/utilities/configurableProviders.service.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Injectable } from "@angular/core"; -import { BaseService } from '@common/base/base.service'; -import { ConfigurableProvider } from '@app/core/model/configurable-provider/configurableProvider'; - -@Injectable() -export class ConfigurableProvidersService extends BaseService { - - public providers: ConfigurableProvider[]; - - constructor( - ) { - super(); - } - -} diff --git a/dmp-frontend/src/app/ui/auth/login/zenodo-login/zenodo-login.component.html b/dmp-frontend/src/app/ui/auth/login/zenodo-login/zenodo-login.component.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/auth/login/zenodo-login/zenodo-login.component.scss b/dmp-frontend/src/app/ui/auth/login/zenodo-login/zenodo-login.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/auth/login/zenodo-login/zenodo-login.component.ts b/dmp-frontend/src/app/ui/auth/login/zenodo-login/zenodo-login.component.ts deleted file mode 100644 index 62d68812a..000000000 --- a/dmp-frontend/src/app/ui/auth/login/zenodo-login/zenodo-login.component.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { Component, OnInit } from '@angular/core'; -import { UntypedFormControl } from '@angular/forms'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { OrcidUser } from '@app/core/model/orcid/orcidUser'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { LoginService } from '@app/ui/auth/login/utilities/login.service'; -import { BaseComponent } from '@common/base/base.component'; -import { environment } from 'environments/environment'; -import { takeUntil } from 'rxjs/operators'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { ZenodoToken } from '@app/core/model/zenodo/zenodo-token.model'; - -@Component({ - selector: 'app-zenodo-login', - templateUrl: './zenodo-login.component.html', - styleUrls: ['./zenodo-login.component.scss'] -}) -export class ZenodoLoginComponent extends BaseComponent implements OnInit { - - private returnUrl: string; - private zenodoToken: ZenodoToken - private accessToken: string; - private emailFormControl = new UntypedFormControl(''); - - constructor( - private route: ActivatedRoute, - private authService: AuthService, - private loginService: LoginService, - private httpClient: HttpClient, - private configurationService: ConfigurationService, - private router: Router - ) { - super(); - this.zenodoToken = new ZenodoToken; - } - - ngOnInit(): void { - this.route.queryParams - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - // const returnUrl = params['returnUrl']; - // if (returnUrl) { this.returnUrl = returnUrl; } - // if (!params['code']) { this.zenodoAccessGetAuthCode(); } else { this.zenodoLogin(params['code']); } - this.router.navigate(['/oauth2'], {queryParams: params}); - }); - } - - public zenodoAccessGetAuthCode() { - window.location.href = this.configurationService.loginProviders.zenodoConfiguration.oauthUrl - + '?client_id=' - + this.configurationService.loginProviders.zenodoConfiguration.clientId - + '&response_type=code&scope=deposit:write+deposit:actions+user:email&state=astate&redirect_uri=' - + this.configurationService.loginProviders.zenodoConfiguration.redirectUri; - } - - public zenodoLogin(code: string) { - // let headers = new HttpHeaders(); - // headers = headers.set('Content-Type', 'application/json'); - // headers = headers.set('Accept', 'application/json'); - // this.httpClient.post(this.configurationService.server + 'auth/zenodoRequestToken', { code: code }, { headers: headers }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe((responseData: any) => { - // this.zenodoToken.userId = responseData.payload.userId; - // this.zenodoToken.expiresIn = responseData.payload.expiresIn; - // this.accessToken = this.zenodoToken.accessToken = responseData.payload.accessToken; - // this.zenodoToken.email = responseData.payload.email; - // this.zenodoToken.refreshToken = responseData.payload.refreshToken; - // this.authService.login({ ticket: this.accessToken, provider: AuthProvider.Zenodo, data: this.zenodoToken }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ); - // }); - } - - public login() { - // this.zenodoToken.email = this.emailFormControl.value; - // this.authService.login({ ticket: this.accessToken, provider: AuthProvider.Zenodo, data: this.zenodoToken }) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // res => this.loginService.onLogInSuccess(res, this.returnUrl), - // error => this.loginService.onLogInError(error) - // ); - } -} diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index 1023b167b..bb9fb4868 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -917,13 +917,5 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { // }); // } - // getAccessUrl(): string { - // const redirectUri = this.configurationService.app + 'oauth2'; - // const url = this.configurationService.loginProviders.zenodoConfiguration.oauthUrl - // + '?client_id=' + this.configurationService.loginProviders.zenodoConfiguration.clientId - // + '&response_type=code&scope=deposit:write+deposit:actions+user:email&state=astate&redirect_uri=' - // + redirectUri; - // return url; - // } } diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts index 4a20a67da..ac8707365 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts @@ -268,8 +268,8 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes getAccessUrl(): string { const redirectUri = this.configurationService.app + 'oauth2'; - const url = this.configurationService.loginProviders.zenodoConfiguration.oauthUrl - + '?client_id=' + this.configurationService.loginProviders.zenodoConfiguration.clientId + const url = this.configurationService.zenodoConfiguration.oauthUrl + + '?client_id=' + this.configurationService.zenodoConfiguration.clientId + '&response_type=code&scope=deposit:write+deposit:actions+user:email&state=astate&redirect_uri=' + redirectUri; return url; diff --git a/dmp-frontend/src/assets/config/config.json b/dmp-frontend/src/assets/config/config.json index c9a7363bf..aa1530c15 100644 --- a/dmp-frontend/src/assets/config/config.json +++ b/dmp-frontend/src/assets/config/config.json @@ -61,42 +61,10 @@ "clientSecret": null, "grantType": "code" }, - "loginProviders": { - "enabled": [1, 2, 3, 4, 5, 6, 7, 8], - "facebookConfiguration": { "clientId": "" }, - "googleConfiguration": { "clientId": "" }, - "linkedInConfiguration": { - "clientId": "", - "oauthUrl": "https://www.linkedin.com/oauth/v2/authorization", - "redirectUri": "http://localhost:4200/login/linkedin", - "state": "987654321" - }, - "twitterConfiguration": { - "clientId": "", - "oauthUrl": "https://api.twitter.com/oauth/authenticate" - }, - "b2accessConfiguration": { - "clientId": "", - "oauthUrl": "https://b2access-integration.fz-juelich.de:443/oauth2-as/oauth2-authz", - "redirectUri": "http://localhost:4200/api/oauth/authorized/b2access", - "state": "" - }, - "orcidConfiguration": { - "clientId": "", - "oauthUrl": "https://orcid.org/oauth/authorize", - "redirectUri": "http://localhost:4200/login/external/orcid" - }, - "openAireConfiguration": { - "clientId": "", - "oauthUrl": "", - "redirectUri": "", - "state": "987654321" - }, - "zenodoConfiguration": { - "clientId": "", - "oauthUrl": "https://sandbox.zenodo.org/oauth/authorize", - "redirectUri": "http://localhost:4200/login/external/zenodo" - } + "zenodoConfiguration": { + "clientId": "", + "oauthUrl": "https://sandbox.zenodo.org/oauth/authorize", + "redirectUri": "http://localhost:4200/login/external/zenodo" }, "logging": { "enabled": true, diff --git a/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.component.html b/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.component.html deleted file mode 100644 index 8889ac050..000000000 --- a/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.component.html +++ /dev/null @@ -1,63 +0,0 @@ -
- -
-Login with - - diff --git a/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.component.scss b/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.component.scss deleted file mode 100644 index 21e8dd73b..000000000 --- a/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.component.scss +++ /dev/null @@ -1,332 +0,0 @@ -.login-screen { - padding-top: 80px; - // margin-top: 70px; - min-height: calc(100vh - 10px); -} - -.login-card { - width: auto; - margin-top: 0; -} - -.container { - padding: 15px 30px; -} - -.card { - box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14); - border-radius: 6px; - color: rgba(0, 0, 0, 0.87); - background: #fff; -} - -.card-raised { - box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.42), 0 4px 25px 0px rgba(0, 0, 0, 0.12), - 0 8px 10px -5px rgba(0, 0, 0, 0.2); -} - -.page-title { - margin-top: 40px; -} - -.container { - height: 100%; - position: relative; - z-index: 1; -} - -@-webkit-keyframes card { - from { - top: -40px; - } - - to { - top: 0; - } -} - -@keyframes card { - from { - top: -40px; - } - - to { - top: 0; - } -} - -.card { - position: relative; - padding: 20px; - display: flex; - flex-direction: column; - align-items: center; - margin-top: 50px; - top: -50px; - -webkit-animation-name: card; - -moz-animation-name: card; - -o-animation-name: card; - animation-name: card; - -webkit-animation-duration: 600ms; - -moz-animation-duration: 600ms; - -o-animation-duration: 600ms; - animation-duration: 600ms; - -webkit-animation-fill-mode: forwards; - -moz-animation-fill-mode: forwards; - -o-animation-fill-mode: forwards; - animation-fill-mode: forwards; -} - -.card-header { - position: relative; - overflow: hidden; - top: -50px; - width: 100%; - min-height: 200px; - padding: 25px; - border-radius: 3px; - background: #0c7489; - // background: rgb(0, 112, 192); - display: flex; - flex-direction: column; - align-items: center; -} - -.card-header h4 { - font-weight: 400; - color: #fff; - margin-bottom: 25px; - margin-top: 5px; -} - -.social-btns { - justify-content: center; -} - -.social-btns i { - font-size: 2.5em; - padding: 0.7em; - color: #767676; -} - -.social-btns .col { - flex-grow: 0; -} - -.social-btns i:hover { - background-color: #f5f5f51c; - border-radius: 60%; -} - -.accesss-methods { - height: 5em; - justify-content: center; -} - -.accesss-methods .col-auto:hover { - background-color: #f5f5f51c; - border-radius: 100%; -} - -.accesss-methods .logo { - flex-grow: 0; - padding-top: 21px; - padding-bottom: 21px; -} - -.accesss-methods .openaire-logo { - flex-grow: 0; - padding-top: 21px; - padding-bottom: 21px; - margin-top: 5px; - height: 90px; -} - -.accesss-methods .orcid-logo { - height: 75px; - padding-top: 8px; - margin-top: 13px; -} - -.accesss-methods .configurable-logo { - flex-grow: 0; - padding-top: 21px; - padding-bottom: 21px; - margin-top: 5px; - height: 90px; -} - -.accesss-methods .zenodo-logo { - height: 75px; - padding-top: 8px; - margin-top: 13px; -} - -.tip { - margin-top: -20px; -} - -.form-row, -.card-form, -.mat-form-field { - width: 100%; -} - -.card-form { - padding: 5px; -} - -.form-row { - position: relative; - display: flex; - align-items: center; - margin-top: 13px; -} - -.form-row i { - position: relative; - top: -5px; - margin-right: 15px; - color: #555; -} - -.card-footer { - padding: 0; - border-radius: 0; - align-items: start; - flex-direction: column; -} - -.card-footer button { - color: #e91e63; -} - -.btn span.icon { - background: url(../../../app/ui/auth/login/img/b2access_small.png) no-repeat; - float: left; - width: 45px; - height: 25px; -} - -span.iconmedium { - background: url(../../../app/ui/auth/login/img/b2access_medium.png) no-repeat; - float: left; - width: 100px; - height: 56px; -} - -span.orcidIconMedium { - background: url(../../../app/ui/auth/login/img/ORCIDiD_medium.png) no-repeat; - background-position: center; - float: right; - width: 56px; - height: 56px; -} - -span.openaireIcon { - background: url(../../../app/ui/auth/login/img/openaire_small.png) no-repeat; - background-position: center; - float: right; - width: 80px; - height: 56px; -} - -span.configurableIcon { - float: right; - width: 80px; - height: 56px; -} - -span.zenodoIcon { - background: url(../../../app/ui/auth/login/img/zenodo-white-200.png) no-repeat 100px 56px; - background-position: center; - float: right; - width: 150px; - height: 56px; -} - -.b2access-button { - margin-top: 10px; - width: fit-content; -} - -.orcid-button { - margin-top: 10px; - width: fit-content; -} - -.openaire-button { - margin-top: 10px; - width: fit-content; -} - -.configurable-button { - margin-top: 10px; - width: fit-content; -} - -.zenodo-button { - margin-top: 10px; - width: fit-content; -} - -.login-logo { - background: url(../../../app/ui/auth/login/img/open-dmp.png) no-repeat; - width: 273px; - height: 300px; - background-size: cover; -} - -.login-bg { - background: url(../../../app/ui/auth/login/img/login_bg.png) no-repeat; - background-size: cover; -} - -.login-social-button { - width: auto; - height: auto; - color: rgba(0, 0, 0, 0.14); -} - -.login-sub { - color: #B8B8B8; -} - -@media (min-width: 1200px) { - .container { - width: 100%; - } -} - -@media (min-width: 992px) { - .container { - width: 100%; - } -} - -@media (min-width: 768px) { - .container { - width: 100%; - } -} - -@media (min-width: 401px) and (max-width: 560px) { - .social-btns i { - padding: 0.4em !important; - } - .accesss-methods { - padding-top: 1em; - } -} - -@media (min-width: 0px) and (max-width: 400px) { - .social-btns i { - padding: 0.4em !important; - } - .card-header { - height: 350px !important; - } - .accesss-methods { - padding-top: 1em; - } -} diff --git a/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.component.ts b/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.component.ts deleted file mode 100644 index 13e4a02ce..000000000 --- a/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.component.ts +++ /dev/null @@ -1,224 +0,0 @@ -import { Component, Inject, AfterViewInit, OnInit } from '@angular/core'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { Router, ActivatedRoute, Params } from '@angular/router'; -import { ConfigurableProvidersService } from '@app/ui/auth/login/utilities/configurableProviders.service'; -import { LoginService } from '@app/ui/auth/login/utilities/login.service'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { BaseComponent } from '@common/base/base.component'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { ConfigurableProvider } from '@app/core/model/configurable-provider/configurableProvider'; -import { takeUntil } from 'rxjs/operators'; - -/// -/// - -declare const gapi: any; -declare const FB: any; - -@Component({ - selector: 'app-sign-in-dialog', - templateUrl: './sign-in-dialog.component.html', - styleUrls: ['./sign-in-dialog.component.scss'] -}) -export class SignInDialogComponent extends BaseComponent implements OnInit, AfterViewInit { - - agreePrivacyPolicyNames = false; - public auth2: any; - private returnUrl: string; - //public cofigurableProviders: ConfigurableProvider[]; - - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - - private router: Router, - private route: ActivatedRoute, - private loginService: LoginService, - private authService: AuthService, - public configurableProviderService: ConfigurableProvidersService, - private configurationService: ConfigurationService - ) { - super(); - } - - close() { - this.dialogRef.close(false); - } - - // cancel() { - // this.dialogRef.close(false); - // } - - // confirm() { - // this.dialogRef.close(true); - // } - - ngOnInit(): void { - this.route.queryParams - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - const returnUrl = params['returnUrl']; - if (returnUrl) { this.returnUrl = returnUrl; } - }); - this.authService.getConfigurableProviders() - .pipe(takeUntil(this._destroyed)) - .subscribe((data: any) => { - this.configurableProviderService.providers = data; - }) - } - - ngAfterViewInit() { - this.initProviders(); - } - - public linkedInLogin() { - this.router.navigate(['/login/linkedin']); - } - - public twitterLogin() { - this.router.navigate(['/login/twitter']); - } - - public b2AccessLogin() { - this.router.navigate(['/login/external/b2access']); - } - - public orcidLogin() { - this.router.navigate(['/login/external/orcid']); - } - - public openaireLogin() { - this.router.navigate(['/login/openaire']); - } - - public configurableLogin(provider: ConfigurableProvider) { - this.router.navigate(['/login/configurable/' + provider.configurableLoginId]) - } - - public zenodoLogin() { - this.router.navigate(['/login/external/zenodo']); - } - - public hasFacebookOauth(): boolean { - return this.hasProvider(AuthProvider.Facebook); - } - - public hasLinkedInOauth(): boolean { - return this.hasProvider(AuthProvider.LinkedIn); - } - - public hasTwitterOauth(): boolean { - return this.hasProvider(AuthProvider.Twitter); - } - - public hasGoogleOauth(): boolean { - return this.hasProvider(AuthProvider.Google); - } - - public hasB2AccessOauth(): boolean { - return this.hasProvider(AuthProvider.B2Access); - } - - public hasOrcidOauth(): boolean { - return this.hasProvider(AuthProvider.ORCID); - } - - public hasOpenAireOauth(): boolean { - return this.hasProvider(AuthProvider.OpenAire); - } - - public hasZenodoOauth(): boolean { - return this.hasProvider(AuthProvider.Zenodo); - } - - public initProviders() { - if (this.hasProvider(AuthProvider.Google)) { this.initializeGoogleOauth(); } - if (this.hasProvider(AuthProvider.Facebook)) { this.initializeFacebookOauth(); } - } - - public hasProvider(provider: AuthProvider) { - for (let i = 0; i < this.configurationService.loginProviders.enabled.length; i++) { - if (provider === this.configurationService.loginProviders.enabled[i]) { return this.isProviderProperlyConfigured(provider); } - } - return false; - } - - private isProviderProperlyConfigured(provider: AuthProvider) { - switch (provider) { - case AuthProvider.Facebook: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.facebookConfiguration); - case AuthProvider.Google: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.googleConfiguration); - case AuthProvider.LinkedIn: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.linkedInConfiguration); - case AuthProvider.Twitter: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.twitterConfiguration); - case AuthProvider.B2Access: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.b2accessConfiguration); - case AuthProvider.ORCID: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.orcidConfiguration); - case AuthProvider.OpenAire: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.openAireConfiguration); - case AuthProvider.Zenodo: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.zenodoConfiguration); - default: throw new Error('Unsupported Provider Type'); - } - } - - private hasAllRequiredFieldsConfigured(configuration: any) { - if (configuration != null && configuration.clientId != null) { return true; } - return false; - } - - /* - * GOOGLE SIGN IN - */ - private initializeGoogleOauth(): void { - gapi.load('auth2', () => { - this.auth2 = gapi.auth2.init({ - client_id: this.configurationService.loginProviders.googleConfiguration.clientId, - scope: 'profile email' - }); - this.attachGoogleSignΙn(document.getElementById('googleSignInButton')); - }); - } - - public attachGoogleSignΙn(element) { - if (!element) { return; } - this.auth2.attachClickHandler(element, {}, - (googleUser) => { - const id_token = googleUser.getAuthResponse().id_token; - if (id_token) { - this.authService.login({ ticket: id_token, provider: AuthProvider.Google }) - .pipe(takeUntil(this._destroyed)) - .subscribe( - res => this.loginService.onLogInSuccess(res, this.returnUrl), - error => this.loginService.onLogInError(error) - ); - } - }, (error) => { - }); - } - - /* - * FACEBOOK SIGN IN - */ - private initializeFacebookOauth(): void { - FB.init({ - appId: this.configurationService.loginProviders.facebookConfiguration.clientId, - cookie: false, - xfbml: true, - version: 'v2.8' - }); - } - - public facebookLogin() { - FB.login((response: any) => { - if (response.status === 'connected' || 'not_authorized') { - this.authService.login({ ticket: response.authResponse.accessToken, provider: AuthProvider.Facebook }) - .pipe(takeUntil(this._destroyed)) - .subscribe( - res => this.loginService.onLogInSuccess(res, this.returnUrl), - error => this.loginService.onLogInError(error) - ); - } - }, { scope: 'email' }); - } - - public hasConfigurableProviders(): boolean { - return !(this.configurableProviderService.providers == undefined) && this.configurableProviderService.providers.length > 0 - } -} diff --git a/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.module.ts b/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.module.ts deleted file mode 100644 index c07e5c9d9..000000000 --- a/dmp-frontend/src/common/modules/sign-in-dialog/sign-in-dialog.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { CommonUiModule } from '@common/ui/common-ui.module'; -import { SignInDialogComponent } from './sign-in-dialog.component'; - -@NgModule({ - imports: [CommonUiModule, FormsModule], - declarations: [SignInDialogComponent], - exports: [SignInDialogComponent], - entryComponents: [SignInDialogComponent] -}) -export class SignInDialogModule { - constructor() { } -} diff --git a/dmp-frontend/src/environments/environment.prod.ts b/dmp-frontend/src/environments/environment.prod.ts index 601551986..5e81ce5e9 100644 --- a/dmp-frontend/src/environments/environment.prod.ts +++ b/dmp-frontend/src/environments/environment.prod.ts @@ -7,31 +7,10 @@ export const environment = { Url: 'https://devel.opendmp.eu/content-service/', }, defaultCulture: 'en-US', - loginProviders: { - enabled: [1, 2, 3, 4, 5, 6], - facebookConfiguration: { clientId: '' }, - googleConfiguration: { clientId: '' }, - linkedInConfiguration: { - clientId: '', - oauthUrl: 'https://www.linkedin.com/oauth/v2/authorization', - redirectUri: 'http://localhost:4200/login/linkedin', - state: '' - }, - twitterConfiguration: { - clientId: '', - oauthUrl: 'https://api.twitter.com/oauth/authenticate' - }, - b2accessConfiguration: { - clientId: '', - oauthUrl: 'https://b2access-integration.fz-juelich.de:443/oauth2-as/oauth2-authz', - redirectUri: 'http://opendmp.eu/api/oauth/authorized/b2access', - state: '' - }, - orcidConfiguration: { - clientId: 'APP-766DI5LP8T75FC4R', - oauthUrl: 'https://sandbox.orcid.org/oauth/authorize', - redirectUri: 'http://opendmp.eu/api/oauth/authorized/orcid' - } + zenodoConfiguration: { + clientId: "", + oauthUrl: "", + redirectUri: "" }, logging: { enabled: false, diff --git a/dmp-frontend/src/environments/environment.staging.ts b/dmp-frontend/src/environments/environment.staging.ts index 63cfd85e5..5e81ce5e9 100644 --- a/dmp-frontend/src/environments/environment.staging.ts +++ b/dmp-frontend/src/environments/environment.staging.ts @@ -7,31 +7,10 @@ export const environment = { Url: 'https://devel.opendmp.eu/content-service/', }, defaultCulture: 'en-US', - loginProviders: { - enabled: [1, 2, 3, 4, 5, 6], - facebookConfiguration: { clientId: '' }, - googleConfiguration: { clientId: '596924546661-83nhl986pnrpug5h624i5kptuao03dcd.apps.googleusercontent.com' }, - linkedInConfiguration: { - clientId: '', - oauthUrl: 'https://www.linkedin.com/oauth/v2/authorization', - redirectUri: 'https://devel.opendmp.eu/login/linkedin', - state: '' - }, - twitterConfiguration: { - clientId: '', - oauthUrl: 'https://api.twitter.com/oauth/authenticate' - }, - b2accessConfiguration: { - clientId: '', - oauthUrl: 'https://b2access-integration.fz-juelich.de:443/oauth2-as/oauth2-authz', - redirectUri: 'http://devel.opendmp.eu/api/oauth/authorized/b2access', - state: '' - }, - orcidConfiguration: { - clientId: '', - oauthUrl: 'https://sandbox.orcid.org/oauth/authorize', - redirectUri: 'http://opendmp.eu/api/oauth/authorized/orcid' - } + zenodoConfiguration: { + clientId: "", + oauthUrl: "", + redirectUri: "" }, logging: { enabled: false, diff --git a/dmp-frontend/src/environments/environment.ts b/dmp-frontend/src/environments/environment.ts index ab3e5f23b..cf5594834 100644 --- a/dmp-frontend/src/environments/environment.ts +++ b/dmp-frontend/src/environments/environment.ts @@ -7,37 +7,10 @@ export const environment = { Url: 'localhost:5000/', }, defaultCulture: 'en-US', - loginProviders: { - enabled: [1, 2, 3, 4, 5, 6, 7, 8], - facebookConfiguration: { clientId: '' }, - googleConfiguration: { clientId: '' }, - linkedInConfiguration: { - clientId: '', - oauthUrl: 'https://www.linkedin.com/oauth/v2/authorization', - redirectUri: 'http://localhost:4200/login/linkedin', - state: '987654321' - }, - twitterConfiguration: { - clientId: '', - oauthUrl: 'https://api.twitter.com/oauth/authenticate' - }, - b2accessConfiguration: { - clientId: '', - oauthUrl: 'https://b2access-integration.fz-juelich.de:443/oauth2-as/oauth2-authz', - redirectUri: 'http://localhost:4200/api/oauth/authorized/b2access', - state: '' - }, - orcidConfiguration: { - clientId: 'APP-766DI5LP8T75FC4R', - oauthUrl: 'https://orcid.org/oauth/authorize', - redirectUri: 'http://localhost:4200/login/external/orcid' - }, - openAireConfiguration: { - clientId: '', - oauthUrl: '', - redirectUri: '', - state: '987654321' - } + zenodoConfiguration: { + clientId: "", + oauthUrl: "", + redirectUri: "" }, logging: { enabled: true,