gnunet-svn
[Top][All Lists]
Advanced

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

[reclaim-ui] 225/459: added logout url to webfinger


From: gnunet
Subject: [reclaim-ui] 225/459: added logout url to webfinger
Date: Fri, 11 Jun 2021 23:25:17 +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 cf2dec307990d4eb3f5db90234d57ea8a301807c
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Wed Jun 24 09:43:17 2020 +0200

    added logout url to webfinger
---
 src/app/attestation.service.ts                     |  7 +--
 src/app/authorization.ts                           |  3 +-
 src/app/edit-identity/edit-identity.component.html |  4 +-
 src/app/edit-identity/edit-identity.component.ts   | 57 ++++++++++++++--------
 src/app/idProvider.ts                              |  6 +++
 5 files changed, 52 insertions(+), 25 deletions(-)

diff --git a/src/app/attestation.service.ts b/src/app/attestation.service.ts
index 4402505..ec8b268 100644
--- a/src/app/attestation.service.ts
+++ b/src/app/attestation.service.ts
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core'
 import { Observable } from 'rxjs';
 import { ConfigService } from './config.service'
 import { AuthConfig } from 'angular-oauth2-oidc';
+import { IdProvider } from './idProvider';
 
 @Injectable()
 export class AttestationService {
@@ -14,17 +15,17 @@ export class AttestationService {
         return this.http.get<any>(this.config.get().webfingerUrl + 
'/.well-known/webfinger?resource=acct:' + email);
     }
 
-    getOauthConfig(idProvider: string){
+    getOauthConfig(idProvider: IdProvider){
         const authCodeFlowConfig: AuthConfig = {
           // Url of the Identity Provider
-          issuer: idProvider,
+          issuer: idProvider.url,
       
           // URL of the SPA to redirect the user to after login
           redirectUri: window.location.href,
 
           postLogoutRedirectUri: window.location.href,
 
-          logoutUrl: idProvider + '/logout',
+          logoutUrl: idProvider.logoutURL + '/logout',
       
           // The SPA's id. The SPA is registerd with this id at the auth-server
           // clientId: 'server.code',
diff --git a/src/app/authorization.ts b/src/app/authorization.ts
index b69af78..1704f57 100644
--- a/src/app/authorization.ts
+++ b/src/app/authorization.ts
@@ -4,5 +4,6 @@ export interface Authorization{
     redirectUri: string,
     clientId: string,
     accessToken: string,
-    idToken: string
+    idToken: string,
+    logoutURL: string
 }
\ No newline at end of file
diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index 45e36d1..bd72498 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -165,7 +165,7 @@
     </button>
     <!--Link account-->
     <button *ngIf="isExperimental() && newIdProviderDiscovered() && 
!grantedAccessToIdProvider()" class="btn btn-primary mb-4 fhg-link" 
(click)="loginFhgAccount()">
-      <span class="fa fa-user"></span> Grant Access to 
{{getNewIdProviderName()}}
+      <span class="fa fa-user"></span> Grant Access to {{newIdProvider.name}}
     </button>
     <!--Save account-->
     <div *ngIf="isExperimental() && newIdProviderDiscovered() && 
grantedAccessToIdProvider()" class="input-group my-2 col-lg-4">
@@ -178,7 +178,7 @@
       <span class="fa fa-warning"></span> You already have an attestation with 
this name.
     </div>
     <button *ngIf="isExperimental() && newIdProviderDiscovered() && 
grantedAccessToIdProvider()" [disabled]="attestationNameDuplicate() || 
newAttestation.name==''" class="btn btn-primary mb-4 fhg-link" 
(click)="saveIdProvider()">
-      <span class="fa fa-user"></span> Save {{getNewIdProviderName()}} Account
+      <span class="fa fa-user"></span> Save {{newIdProvider.name}} Account
     </button>
     <button *ngIf="isExperimental() && newIdProviderDiscovered()" class="btn 
btn-primary mb-4 fhg-link" (click)="cancleLinking()">
       Cancle Linking
diff --git a/src/app/edit-identity/edit-identity.component.ts 
b/src/app/edit-identity/edit-identity.component.ts
index a28d7e3..f3e0631 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -13,6 +13,7 @@ import { from, forkJoin, EMPTY } from 'rxjs';
 import { AttestationService } from '../attestation.service';
 import { OAuthService } from 'angular-oauth2-oidc';
 import { Authorization } from '../authorization';
+import { IdProvider } from '../idProvider';
 
 
 @Component({
@@ -36,7 +37,7 @@ export class EditIdentityComponent implements OnInit {
   optionalAttested: Attribute[];
   webfingerEmail: string;
   authorizations: Authorization[];
-  newIdProvider: string;
+  newIdProvider: IdProvider;
   emailNotFoundAlertClosed: boolean;
 
   constructor(private reclaimService: ReclaimService,
@@ -55,15 +56,16 @@ export class EditIdentityComponent implements OnInit {
     this.optionalAttested = [];
     this.attestationValues = {};
     this.webfingerEmail = '';
-    this.newIdProvider = localStorage.getItem('newIdProvider') || '';
     this.emailNotFoundAlertClosed = true;
+    this.newIdProvider = new IdProvider ('', '', '');
+    this.loadIdProviderFromLocalStorage();
     this.loadAuthorizationsFromLocalStorage();
     this.identity = new Identity('','');
     this.newAttribute = new Attribute('', '', '', '', 'STRING', '');
     this.newAttested = new Attribute('', '', '', '', 'STRING', '');
     this.newAttestation = new Attestation('', '', '', 'JWT', '', null, []);
 
-    if (this.newIdProvider !== ''){
+    if (this.newIdProvider.url !== ''){
       
this.oauthService.configure(this.attestationService.getOauthConfig(this.newIdProvider));
       this.oauthService.loadDiscoveryDocumentAndTryLogin();
     }
@@ -639,8 +641,11 @@ export class EditIdentityComponent implements OnInit {
     localStorage.setItem('userForAttestation', this.identity.name);
     this.isValidEmailforDiscovery();
     this.attestationService.getLink(this.webfingerEmail).subscribe (idProvider 
=> {
-      this.newIdProvider = (idProvider.links [0]).href; 
-      localStorage.setItem('newIdProvider', this.newIdProvider);
+      this.newIdProvider.url = (idProvider.links [0]).href; 
+      localStorage.setItem('newIdProviderURL', this.newIdProvider.url);
+      this.newIdProvider.name = 
this.getNewIdProviderName(this.newIdProvider.url);
+      (idProvider.links.length > 1)? this.newIdProvider.logoutURL = 
(idProvider.links [1]).href : this.newIdProvider.logoutURL = 
this.newIdProvider.url;
+       localStorage.setItem('newIdProviderLogoutURL', 
this.newIdProvider.logoutURL);
       console.log(this.newIdProvider);
       this.webfingerEmail == '';
     },
@@ -665,7 +670,7 @@ export class EditIdentityComponent implements OnInit {
   //not sure if needed -> should be able to link two different accounts from 
same provider
   discoveredIdProviderExistsAlready(){
     this.authorizations.forEach(token => {
-      if (token.idProvider == this.newIdProvider){
+      if (token.idProvider == this.newIdProvider.url){
         return true;
       }
     });
@@ -673,14 +678,14 @@ export class EditIdentityComponent implements OnInit {
   }
 
   newIdProviderDiscovered(){
-    if (this.newIdProvider == ''){
+    if (this.newIdProvider.url == ''){
       return false;
     }
     return true;
   }
 
-  getNewIdProviderName(){
-    return this.newIdProvider.split('//')[1];
+  getNewIdProviderName(url: string){
+    return url.split('//')[1];
   }
 
   loginFhgAccount(){
@@ -692,15 +697,16 @@ export class EditIdentityComponent implements OnInit {
 
   saveIdProviderinLocalStorage(){
     const newAuthorization: Authorization = {
-      idProvider: this.newIdProvider,
+      idProvider: this.newIdProvider.url,
       attestationName: this.newAttestation.name,
       redirectUri: this.oauthService.redirectUri,
       clientId: this.oauthService.clientId,
       accessToken: this.getAccessToken(),
-      idToken: this.oauthService.getIdToken()
+      idToken: this.oauthService.getIdToken(),
+      logoutURL: this.newIdProvider.logoutURL
     }
     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());
+    localStorage.setItem('Authorization: ' + this.newAttestation.name, 
'idProvider: ' + this.newIdProvider.url + ';redirectUri: ' +  
this.oauthService.redirectUri + ';clientId: ' + this.oauthService.clientId + 
';accessToken: ' + this.getAccessToken() + ';idToken: ' + 
this.oauthService.getIdToken() + ';logoutURL: ' + this.newIdProvider.logoutURL);
   }
 
   addAttestation() {
@@ -708,8 +714,7 @@ export class EditIdentityComponent implements OnInit {
     this.reclaimService.addAttestation(this.identity, 
this.newAttestation).subscribe(res => {
       console.log("Saved Attestation");
       console.log(res);
-      this.newIdProvider = '';
-      localStorage.removeItem('newIdProvider');
+      this.resetNewIdProvider();
       this.updateAttestations();
       this.newAttestation.name = '';
       this.newAttestation.value = '';
@@ -761,6 +766,12 @@ export class EditIdentityComponent implements OnInit {
     return false;
   }
 
+  loadIdProviderFromLocalStorage(){
+    this.newIdProvider.url = localStorage.getItem("newIdProviderURL") || '';
+    this.newIdProvider.name = 
this.getNewIdProviderName(this.newIdProvider.url);
+    this.newIdProvider.logoutURL = 
localStorage.getItem("newIdProviderLogoutURL") || '';
+  }
+
   loadAuthorizationsFromLocalStorage(){
     this.authorizations = [];
     var potentialIdProviders = Object.keys(localStorage);
@@ -772,7 +783,8 @@ export class EditIdentityComponent implements OnInit {
           redirectUri: '',
           clientId: '',
           accessToken: '',
-          idToken: ''
+          idToken: '',
+          logoutURL: '',
         }
         var content = localStorage.getItem(element);
         content.split(";").forEach(authInfo => {
@@ -797,11 +809,18 @@ export class EditIdentityComponent implements OnInit {
 
   cancleLinking(){
     this.logOutFromOauthService();
-    this.newIdProvider = '';
-    localStorage.removeItem('newIdProvider');
+    this.resetNewIdProvider();
     this.webfingerEmail = '';
   }
 
+  resetNewIdProvider(){
+    this.newIdProvider.url = '';
+    this.newIdProvider.logoutURL = '';
+    this.newIdProvider.name = '';
+    localStorage.removeItem('newIdProviderURL');
+    localStorage.removeItem('newIdProviderLogoutURL')
+  }
+
   getAttestationExpiration(){
     return this.oauthService.getIdTokenExpiration()
   }
@@ -813,8 +832,8 @@ export class EditIdentityComponent implements OnInit {
       console.log(attributeKey);
       var tempAttribute: Attribute = {
         name: attributeKey,
-        id: this.newIdProvider, //Don't think this is correct id
-        attestation: this.newIdProvider,
+        id: this.newIdProvider.url, //Don't think this is correct id
+        attestation: this.newIdProvider.url,
         value: attributesObject[attributeKey],
         type: 'STRING',
         flag: '1',
diff --git a/src/app/idProvider.ts b/src/app/idProvider.ts
new file mode 100644
index 0000000..1343d1a
--- /dev/null
+++ b/src/app/idProvider.ts
@@ -0,0 +1,6 @@
+export class IdProvider {
+    constructor(
+        public url: string,
+        public logoutURL: string,
+        public name: string){}
+}
\ No newline at end of file

-- 
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]