gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[reclaim-ui] 216/459: idProvider stored in localStorage and loaded to au


From: gnunet
Subject: [reclaim-ui] 216/459: idProvider stored in localStorage and loaded to authorization interface
Date: Fri, 11 Jun 2021 23:25:08 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository reclaim-ui.

commit 75dc44e3a8a27e3f3395600672be5a034e5ff1a3
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Wed Jun 17 10:30:29 2020 +0200

    idProvider stored in localStorage and loaded to authorization interface
---
 src/app/accessToken.ts                             |  4 --
 src/app/attestation.ts                             |  2 +-
 src/app/authorization.ts                           |  8 ++++
 .../edit-attestations.component.html               |  2 +-
 src/app/edit-identity/edit-identity.component.html |  6 +--
 src/app/edit-identity/edit-identity.component.ts   | 51 +++++++++++++++-------
 src/app/reclaim.service.ts                         |  4 +-
 src/app/webfinger.service.ts                       |  4 --
 8 files changed, 48 insertions(+), 33 deletions(-)

diff --git a/src/app/accessToken.ts b/src/app/accessToken.ts
deleted file mode 100644
index d14e7e7..0000000
--- a/src/app/accessToken.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export interface AccessToken {
-    idProvider: string;
-    accessToken: string;
-}
\ No newline at end of file
diff --git a/src/app/attestation.ts b/src/app/attestation.ts
index 64fdb44..dfc40ff 100644
--- a/src/app/attestation.ts
+++ b/src/app/attestation.ts
@@ -5,7 +5,7 @@ export class Attestation {
               public id: string,
               public value: string,
               public type: string,
-              public iss: string,
+              public issuer: string,
               public expiration: number,
               public attributes: Attribute[]) {}
 }
diff --git a/src/app/authorization.ts b/src/app/authorization.ts
new file mode 100644
index 0000000..b69af78
--- /dev/null
+++ b/src/app/authorization.ts
@@ -0,0 +1,8 @@
+export interface Authorization{
+    idProvider: string,
+    attestationName: string,
+    redirectUri: string,
+    clientId: string,
+    accessToken: string,
+    idToken: string
+}
\ No newline at end of file
diff --git a/src/app/edit-attestations/edit-attestations.component.html 
b/src/app/edit-attestations/edit-attestations.component.html
index 971779f..d96ec35 100644
--- a/src/app/edit-attestations/edit-attestations.component.html
+++ b/src/app/edit-attestations/edit-attestations.component.html
@@ -31,7 +31,7 @@
             <div style="min-width: 15em">
             </div>
 </td>-->
-          <td><div style="min-width: 15em">{{attestation.iss}}</div></td>
+          <td><div style="min-width: 15em">{{attestation.issuer}}</div></td>
           <td>
             <button class="btn btn-primary"  
(click)="deleteAttestation(attestation)">
               <span class="fa fa-trash"></span>
diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index e4bc2fa..076b8bb 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -159,16 +159,12 @@
     <div *ngIf="!emailNotFoundAlertClosed && webfingerEmail==''" class="alert 
alert-danger alert-dismissible fade show my-2" role="alert">
       <span class="fa fa-warning"></span> No account found with this email
     </div>
-    <!--IdProvider Exists already warning-->
-    <div *ngIf="discoveredIdProviderExistsAlready() && webfingerEmail==''" 
class="alert alert-danger alert-dismissible fade show my-2" role="alert">
-      <span class="fa fa-warning"></span> The Provider linked to this website 
is already linked.
-    </div>
     
     <button *ngIf="isExperimental() && !newIdProviderDiscovered()" class="btn 
btn-primary mb-4 fhg-link" (click)="getFhGAttestation()">
       <span class="fa fa-user"></span> Link Fraunhofer Account
     </button>
     <!--Link account-->
-    <button *ngIf="isExperimental() && newIdProviderDiscovered() && 
!discoveredIdProviderExistsAlready() && !grantedAccessToIdProvider()" 
class="btn btn-primary mb-4 fhg-link" (click)="loginFhgAccount()">
+    <button *ngIf="isExperimental() && newIdProviderDiscovered() && 
!grantedAccessToIdProvider()" class="btn btn-primary mb-4 fhg-link" 
(click)="loginFhgAccount()">
       <span class="fa fa-user"></span> Link {{getNewIdProviderName()}} Account
     </button>
     <!--Save account-->
diff --git a/src/app/edit-identity/edit-identity.component.ts 
b/src/app/edit-identity/edit-identity.component.ts
index ef5fa72..392ba21 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -13,7 +13,7 @@ import { from, forkJoin, EMPTY } from 'rxjs';
 import {WebfingerService} from '../webfinger.service';
 import { OAuthService } from 'angular-oauth2-oidc';
 import { OauthHelperService } from '../oauth-helper.service'
-import { AccessToken } from '../accessToken';
+import { Authorization } from '../authorization';
 
 
 @Component({
@@ -36,7 +36,7 @@ export class EditIdentityComponent implements OnInit {
   requestedAttested: Attribute[];
   optionalAttested: Attribute[];
   webfingerEmail: string;
-  accessToken: AccessToken[];
+  authorizations: Authorization[];
   newIdProvider: string;
   emailNotFoundAlertClosed: boolean;
 
@@ -59,7 +59,7 @@ export class EditIdentityComponent implements OnInit {
     this.webfingerEmail = '';
     this.newIdProvider = localStorage.getItem('newIdProvider') || '';
     this.emailNotFoundAlertClosed = true;
-    this.loadAccessTokenFromLocalStorage();
+    this.loadAuthorizationsFromLocalStorage();
     this.identity = new Identity('','');
     this.newAttribute = new Attribute('', '', '', '', 'STRING', '');
     this.newAttested = new Attribute('', '', '', '', 'STRING', '');
@@ -609,7 +609,7 @@ export class EditIdentityComponent implements OnInit {
   getIssuer(attribute: Attribute) {
     for (let i = 0; i < this.attestations.length; i++) {
       if (this.attestations[i].id == attribute.attestation) {
-        return this.attestations[i].iss;
+        return this.attestations[i].issuer;
       }
     }
   }
@@ -657,8 +657,10 @@ export class EditIdentityComponent implements OnInit {
     return true;
   }
 
+
+  //not sure if needed -> should be able to link two different accounts from 
same provider
   discoveredIdProviderExistsAlready(){
-    this.accessToken.forEach(token => {
+    this.authorizations.forEach(token => {
       if (token.idProvider == this.newIdProvider){
         return true;
       }
@@ -684,12 +686,16 @@ export class EditIdentityComponent implements OnInit {
   }
 
   saveIdProviderinLocalStorage(){
-    const newAccessToken: AccessToken = {
+    const newAuthorization: Authorization = {
       idProvider: this.newIdProvider,
+      attestationName: this.newAttestation.name,
+      redirectUri: this.oauthService.redirectUri,
+      clientId: this.oauthService.clientId,
       accessToken: this.getAccessToken(),
+      idToken: this.oauthService.getIdToken()
     }
-    this.accessToken.push(newAccessToken);
-    localStorage.setItem('idProvider:' + this.newIdProvider, "RedirectUri:" +  
this.oauthService.redirectUri + ";ClientId: " + this.oauthService.clientId + "; 
AccessToken: " + this.getAccessToken());
+    this.authorizations.push(newAuthorization);
+    localStorage.setItem("Authorization: " + this.newAttestation.name, 
'idProvider: ' + this.newIdProvider + ";redirectUri: " +  
this.oauthService.redirectUri + ";clientId: " + this.oauthService.clientId + 
";accessToken: " + this.getAccessToken() + ";idToken: " + 
this.oauthService.getIdToken());
   }
 
   addAttestation() {
@@ -709,6 +715,7 @@ export class EditIdentityComponent implements OnInit {
     });
     this.newAttestation.name = '';
     this.newAttestation.value = '';
+    this.logOutFromOauthService
   }
 
   saveIdProvider(){
@@ -732,20 +739,32 @@ export class EditIdentityComponent implements OnInit {
     return false;
   }
 
-  loadAccessTokenFromLocalStorage(){
-    this.accessToken = [];
+  loadAuthorizationsFromLocalStorage(){
+    this.authorizations = [];
     var potentialIdProviders = Object.keys(localStorage);
     potentialIdProviders.forEach(element => {
-      if (element.includes('idProvider')){
-        var idProvider = element.replace('idProvider:', '');
-        const newAccessToken: AccessToken = {
-          idProvider: idProvider,
-          accessToken: localStorage.getItem(idProvider),
+      if (element.includes('Authorization')){
+        const newAuthorization: Authorization = {
+          attestationName: element.replace('Authorization: ', ''),
+          idProvider: '',
+          redirectUri: '',
+          clientId: '',
+          accessToken: '',
+          idToken: ''
+        }
+        var content = localStorage.getItem(element);
+        content.split(";").forEach(authInfo => {
+          var key = authInfo.split(": ")[0];
+          var value = authInfo.split(": ")[1];
+          newAuthorization[key] = value;
         }
-        this.accessToken.push(newAccessToken);
+          )
+  
+        this.authorizations.push(newAuthorization);
       }
       
     });
+    console.log(this.authorizations);
   }
 
   logOutFromOauthService(){
diff --git a/src/app/reclaim.service.ts b/src/app/reclaim.service.ts
index fff97b1..91dc643 100644
--- a/src/app/reclaim.service.ts
+++ b/src/app/reclaim.service.ts
@@ -56,8 +56,8 @@ export class ReclaimService {
   addAttestation(identity: Identity, attestation: Attestation) {
     var json = {
       "name": attestation.name,
-      "type": attestation.type,
-      "value": attestation.value
+      "value": attestation.value,
+      "type": attestation.type
     }
     return this.http.post(this.config.get().apiUrl +
       '/reclaim/attestation/' + identity.name,
diff --git a/src/app/webfinger.service.ts b/src/app/webfinger.service.ts
index 4b1d178..084b1b4 100644
--- a/src/app/webfinger.service.ts
+++ b/src/app/webfinger.service.ts
@@ -3,15 +3,11 @@ import { Injectable } from '@angular/core'
 import { Observable } from 'rxjs';
 import { ConfigService } from './config.service'
 
-// https://github.com/d-koppenhagen/webfinger
-
 @Injectable()
 export class WebfingerService {
 
     constructor(private http: HttpClient, private config: ConfigService) {
     }
-
-    
  
     getLink (email: string): Observable<any>{
         return this.http.get<any>(this.config.get().webfingerUrl + 
'/.well-known/webfinger?resource=acct:' + email);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]