aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-04-20 20:23:50 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-04-20 20:23:50 +0200
commit959a7119ef3be57b5c77f403cfe7dc6117e5cb2f (patch)
treea3ed72648ceaf01e690403a6ddb507d70a139d5a
parent0824ad1a5ddb7033cfdf302a748141138794df10 (diff)
downloadreclaim-ui-959a7119ef3be57b5c77f403cfe7dc6117e5cb2f.tar.gz
reclaim-ui-959a7119ef3be57b5c77f403cfe7dc6117e5cb2f.zip
pabc fixes
-rw-r--r--src/app/edit-identity/edit-identity.component.ts20
-rw-r--r--src/app/pabc.service.ts14
2 files changed, 22 insertions, 12 deletions
diff --git a/src/app/edit-identity/edit-identity.component.ts b/src/app/edit-identity/edit-identity.component.ts
index 21801dc..a6e8513 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -622,30 +622,34 @@ export class EditIdentityComponent implements OnInit {
622 } 622 }
623 /** 623 /**
624 * Check for privacy credential support 624 * Check for privacy credential support
625 * FIXME this is a bug in the angular plugin.
625 */ 626 */
626 let grantedScopes = this.oauthService.getGrantedScopes(); 627 let grantedScopes = this.oauthService.getGrantedScopes();
628 console.log("Granted scopes are " + grantedScopes);
627 if (!Array.isArray(grantedScopes) || 629 if (!Array.isArray(grantedScopes) ||
628 !grantedScopes.includes("pabc")) { 630 !grantedScopes[0].split(' ').includes("pabc")) {
629 this.importAttributesFromCredential(); 631 this.importAttributesFromCredential();
630 return; 632 return;
631 } 633 }
632 console.log("Privacy credentials supported. Trying..."); 634 console.log("Privacy credentials supported. Trying...");
633 this.pabcService.getNonceFromIssuer(this.oauthService 635 //FIXME the omejdn suffix is... problematic
634 .issuer).subscribe(nonceParams => { 636 this.pabcService.getNonceFromIssuer(this.oauthService.issuer + '/omejdn',
637 this.oauthService.getAccessToken()).subscribe(nonceParams => {
635 console.log("Got metadata: " + JSON.stringify(nonceParams)); 638 console.log("Got metadata: " + JSON.stringify(nonceParams));
636 /* Get credential request */ 639 /* Get credential request */
637 let crMetadata = { 640 let crMetadata = {
638 nonce: nonceParams.nonce, 641 nonce: nonceParams.nonce,
639 public_params: nonceParams.public_params, 642 public_params: nonceParams.public_params,
640 issuer: this.oauthService.issuer, 643 issuer: encodeURIComponent(this.oauthService.issuer),
641 id_token: this.oauthService.getIdToken(), 644 id_token: this.oauthService.getIdToken(),
642 identity: this.identity 645 identity: this.identity.pubkey
643 } 646 }
644 this.pabcService.getCredentialRequest(crMetadata).subscribe(cr => { 647 this.pabcService.getCredentialRequest(crMetadata).subscribe(cr => {
645 console.log("Got CR: " + JSON.stringify (cr)); 648 console.log("Got CR: " + JSON.stringify (cr));
646 this.pabcService.getPrivacyCredential(this.oauthService.issuer, 649 this.pabcService.getPrivacyCredential(this.oauthService.issuer + '/omejdn',
647 cr).subscribe(cred => { 650 cr,
648 console.log("Got Credential: " + JSON.stringify (cred)); 651 this.oauthService.getAccessToken()).subscribe(cred => {
652 console.log("Got Credential: " + JSON.stringify(cred));
649 this.newCredential.value = cred; 653 this.newCredential.value = cred;
650 this.newCredential.name = this.importIdProvider.name + "pabc"; 654 this.newCredential.name = this.importIdProvider.name + "pabc";
651 this.newCredential.type = 'pabc'; 655 this.newCredential.type = 'pabc';
diff --git a/src/app/pabc.service.ts b/src/app/pabc.service.ts
index b3f15d7..5eb345f 100644
--- a/src/app/pabc.service.ts
+++ b/src/app/pabc.service.ts
@@ -11,12 +11,18 @@ export class PabcService {
11 11
12 constructor(private http: HttpClient, private config: ConfigService) { } 12 constructor(private http: HttpClient, private config: ConfigService) { }
13 13
14 getNonceFromIssuer(issuer: string): Observable<NonceParams> { 14 getNonceFromIssuer(issuer: string, at: string): Observable<NonceParams> {
15 return this.http.get<NonceParams>(issuer + '/pabc'); 15 const httpHeaders: HttpHeaders = new HttpHeaders({
16 Authorization: 'Bearer ' + at
17});
18 return this.http.get<NonceParams>(issuer + '/pabc', { headers: httpHeaders });
16 } 19 }
17 20
18 getPrivacyCredential(issuer: string, cr: object): Observable<any> { 21 getPrivacyCredential(issuer: string, cr: object, at: string): Observable<any> {
19 return this.http.post<any>(issuer + '/pabc/cr', cr); 22 const httpHeaders: HttpHeaders = new HttpHeaders({
23 Authorization: 'Bearer ' + at
24});
25 return this.http.post<any>(issuer + '/pabc/cr', cr, { headers: httpHeaders });
20 } 26 }
21 27
22 28