aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranna wimbauer <anna.wibauer@gmx.de>2020-06-17 15:39:51 +0200
committeranna wimbauer <anna.wibauer@gmx.de>2020-06-17 15:39:51 +0200
commitd1f96d61843af5ac741c80e6f7ba262f3c4dfad6 (patch)
tree1e938737ec5a9f5780b8252e7cd65b81aa3197ec
parent51e33c85b4102c2ce28911b06dd59c810e96f714 (diff)
downloadreclaim-ui-d1f96d61843af5ac741c80e6f7ba262f3c4dfad6.tar.gz
reclaim-ui-d1f96d61843af5ac741c80e6f7ba262f3c4dfad6.zip
merge webfinger-service and oauth-helper-service into attestation-service
-rw-r--r--src/app/app.module.ts6
-rw-r--r--src/app/attestation.service.ts49
-rw-r--r--src/app/edit-identity/edit-identity.component.ts14
-rw-r--r--src/app/oauth-helper.service.ts40
-rw-r--r--src/app/webfinger.service.ts16
5 files changed, 57 insertions, 68 deletions
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 9d33d97..8d780ae 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -16,8 +16,7 @@ import { ModalComponent } from './modal.component';
16import { ModalService } from './modal.service'; 16import { ModalService } from './modal.service';
17import { SearchPipe } from './search.pipe'; 17import { SearchPipe } from './search.pipe';
18import { OpenIdService } from './open-id.service'; 18import { OpenIdService } from './open-id.service';
19import { WebfingerService } from './webfinger.service'; 19import { AttestationService } from './attestation.service';
20import { OauthHelperService } from './oauth-helper.service';
21import { NewIdentityComponent } from './new-identity/new-identity.component'; 20import { NewIdentityComponent } from './new-identity/new-identity.component';
22import { EditIdentityComponent } from './edit-identity/edit-identity.component'; 21import { EditIdentityComponent } from './edit-identity/edit-identity.component';
23import { AuthorizationRequestComponent } from './authorization-request/authorization-request.component'; 22import { AuthorizationRequestComponent } from './authorization-request/authorization-request.component';
@@ -52,8 +51,7 @@ import { EditAttestationsComponent } from './edit-attestations/edit-attestations
52 GnsService, 51 GnsService,
53 OpenIdService, 52 OpenIdService,
54 ConfigService, 53 ConfigService,
55 OauthHelperService, 54 AttestationService,
56 WebfingerService,
57 { 55 {
58 provide: APP_INITIALIZER, 56 provide: APP_INITIALIZER,
59 useFactory: (config: ConfigService) => () => config.load(), 57 useFactory: (config: ConfigService) => () => config.load(),
diff --git a/src/app/attestation.service.ts b/src/app/attestation.service.ts
new file mode 100644
index 0000000..09038fb
--- /dev/null
+++ b/src/app/attestation.service.ts
@@ -0,0 +1,49 @@
1import { HttpClient, HttpHeaders} from '@angular/common/http';
2import { Injectable } from '@angular/core'
3import { Observable } from 'rxjs';
4import { ConfigService } from './config.service'
5import { AuthConfig } from 'angular-oauth2-oidc';
6
7@Injectable()
8export class AttestationService {
9
10 constructor(private http: HttpClient, private config: ConfigService) {
11 }
12
13 getLink (email: string): Observable<any>{
14 return this.http.get<any>(this.config.get().webfingerUrl + '/.well-known/webfinger?resource=acct:' + email);
15 }
16
17 getOauthConfig(idProvider: string){
18 const authCodeFlowConfig: AuthConfig = {
19 // Url of the Identity Provider
20 issuer: idProvider,
21
22 // URL of the SPA to redirect the user to after login
23 redirectUri: window.location.href,
24
25 // The SPA's id. The SPA is registerd with this id at the auth-server
26 // clientId: 'server.code',
27 clientId: 'reclaimid',
28
29 // Just needed if your auth server demands a secret. In general, this
30 // is a sign that the auth server is not configured with SPAs in mind
31 // and it might not enforce further best practices vital for security
32 // such applications.
33 // dummyClientSecret: 'secret',
34
35 responseType: 'code',
36
37 // set the scope for the permissions the client should request
38 // The first four are defined by OIDC.
39 // Important: Request offline_access to get a refresh token
40 // The api scope is a usecase specific one
41 scope: 'openid profile omejdn:api',
42
43 showDebugInformation: true,
44 };
45
46 return authCodeFlowConfig;
47 }
48
49} \ No newline at end of file
diff --git a/src/app/edit-identity/edit-identity.component.ts b/src/app/edit-identity/edit-identity.component.ts
index 96e982d..b9586ab 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -10,9 +10,8 @@ import { Attestation } from '../attestation';
10import { IdentityService } from '../identity.service'; 10import { IdentityService } from '../identity.service';
11import { finalize } from 'rxjs/operators'; 11import { finalize } from 'rxjs/operators';
12import { from, forkJoin, EMPTY } from 'rxjs'; 12import { from, forkJoin, EMPTY } from 'rxjs';
13import {WebfingerService} from '../webfinger.service'; 13import { AttestationService } from '../attestation.service';
14import { OAuthService } from 'angular-oauth2-oidc'; 14import { OAuthService } from 'angular-oauth2-oidc';
15import { OauthHelperService } from '../oauth-helper.service'
16import { Authorization } from '../authorization'; 15import { Authorization } from '../authorization';
17 16
18 17
@@ -47,9 +46,8 @@ export class EditIdentityComponent implements OnInit {
47 private namestoreService: NamestoreService, 46 private namestoreService: NamestoreService,
48 private activatedRoute: ActivatedRoute, 47 private activatedRoute: ActivatedRoute,
49 private router: Router, 48 private router: Router,
50 private webfingerService: WebfingerService, 49 private attestationService: AttestationService,
51 private oauthService: OAuthService, 50 private oauthService: OAuthService) {}
52 private oauthHelperService: OauthHelperService) {}
53 51
54 ngOnInit() { 52 ngOnInit() {
55 this.attributes = []; 53 this.attributes = [];
@@ -66,7 +64,7 @@ export class EditIdentityComponent implements OnInit {
66 this.newAttestation = new Attestation('', '', '', 'JWT', '', null, []); 64 this.newAttestation = new Attestation('', '', '', 'JWT', '', null, []);
67 65
68 if (this.newIdProvider !== ''){ 66 if (this.newIdProvider !== ''){
69 this.oauthService.configure(this.oauthHelperService.getOauthConfig(this.newIdProvider)); 67 this.oauthService.configure(this.attestationService.getOauthConfig(this.newIdProvider));
70 this.oauthService.loadDiscoveryDocumentAndTryLogin(); 68 this.oauthService.loadDiscoveryDocumentAndTryLogin();
71 } 69 }
72 70
@@ -640,7 +638,7 @@ export class EditIdentityComponent implements OnInit {
640 } 638 }
641 localStorage.setItem('userForAttestation', this.identity.name); 639 localStorage.setItem('userForAttestation', this.identity.name);
642 this.isValidEmailforDiscovery(); 640 this.isValidEmailforDiscovery();
643 this.webfingerService.getLink(this.webfingerEmail).subscribe (idProvider => { 641 this.attestationService.getLink(this.webfingerEmail).subscribe (idProvider => {
644 this.newIdProvider = (idProvider.links [0]).href; 642 this.newIdProvider = (idProvider.links [0]).href;
645 localStorage.setItem('newIdProvider', this.newIdProvider); 643 localStorage.setItem('newIdProvider', this.newIdProvider);
646 console.log(this.newIdProvider); 644 console.log(this.newIdProvider);
@@ -686,7 +684,7 @@ export class EditIdentityComponent implements OnInit {
686 } 684 }
687 685
688 loginFhgAccount(){ 686 loginFhgAccount(){
689 var authCodeFlowConfig = this.oauthHelperService.getOauthConfig(this.newIdProvider); 687 var authCodeFlowConfig = this.attestationService.getOauthConfig(this.newIdProvider);
690 this.oauthService.configure(authCodeFlowConfig); 688 this.oauthService.configure(authCodeFlowConfig);
691 this.oauthService.loadDiscoveryDocumentAndLogin(); 689 this.oauthService.loadDiscoveryDocumentAndLogin();
692 this.getId(); 690 this.getId();
diff --git a/src/app/oauth-helper.service.ts b/src/app/oauth-helper.service.ts
deleted file mode 100644
index dc1dcce..0000000
--- a/src/app/oauth-helper.service.ts
+++ /dev/null
@@ -1,40 +0,0 @@
1import { Injectable } from '@angular/core';
2import { AuthConfig } from 'angular-oauth2-oidc';
3
4@Injectable()
5export class OauthHelperService {
6
7 constructor() { }
8
9 getOauthConfig(idProvider: string){
10 const authCodeFlowConfig: AuthConfig = {
11 // Url of the Identity Provider
12 issuer: idProvider,
13
14 // URL of the SPA to redirect the user to after login
15 redirectUri: window.location.href,
16
17 // The SPA's id. The SPA is registerd with this id at the auth-server
18 // clientId: 'server.code',
19 clientId: 'reclaimid',
20
21 // Just needed if your auth server demands a secret. In general, this
22 // is a sign that the auth server is not configured with SPAs in mind
23 // and it might not enforce further best practices vital for security
24 // such applications.
25 // dummyClientSecret: 'secret',
26
27 responseType: 'code',
28
29 // set the scope for the permissions the client should request
30 // The first four are defined by OIDC.
31 // Important: Request offline_access to get a refresh token
32 // The api scope is a usecase specific one
33 scope: 'openid profile omejdn:api',
34
35 showDebugInformation: true,
36 };
37
38 return authCodeFlowConfig;
39 }
40}
diff --git a/src/app/webfinger.service.ts b/src/app/webfinger.service.ts
deleted file mode 100644
index 084b1b4..0000000
--- a/src/app/webfinger.service.ts
+++ /dev/null
@@ -1,16 +0,0 @@
1import { HttpClient, HttpHeaders} from '@angular/common/http';
2import { Injectable } from '@angular/core'
3import { Observable } from 'rxjs';
4import { ConfigService } from './config.service'
5
6@Injectable()
7export class WebfingerService {
8
9 constructor(private http: HttpClient, private config: ConfigService) {
10 }
11
12 getLink (email: string): Observable<any>{
13 return this.http.get<any>(this.config.get().webfingerUrl + '/.well-known/webfinger?resource=acct:' + email);
14 }
15
16} \ No newline at end of file