gnunet-svn
[Top][All Lists]
Advanced

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

[reclaim-ui] 240/459: scopes after idProviderDiscovery


From: gnunet
Subject: [reclaim-ui] 240/459: scopes after idProviderDiscovery
Date: Fri, 11 Jun 2021 23:25:32 +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 52a4f94ad3732da32f0e68d6ea6882e11e60430c
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Wed Jul 15 15:52:14 2020 +0200

    scopes after idProviderDiscovery
---
 src/app/attestation.service.ts                     | 10 ++++++++
 .../edit-attestations.component.html               | 23 +++++++++++------
 .../edit-attestations.component.ts                 | 30 +++++++++++++++++-----
 src/app/scope.ts                                   |  4 +++
 4 files changed, 53 insertions(+), 14 deletions(-)

diff --git a/src/app/attestation.service.ts b/src/app/attestation.service.ts
index 1330c71..ed3d61f 100644
--- a/src/app/attestation.service.ts
+++ b/src/app/attestation.service.ts
@@ -58,9 +58,19 @@ export class AttestationService {
           scope: 'openid profile',
       
           showDebugInformation: true,  
+
+          requireHttps: false,
         };
     
         return authCodeFlowConfig;
     }
 
+    getDiscoveryDocument(url: string){
+        if (!url.endsWith('/')) {
+            url += '/';
+          }
+          url += '.well-known/openid-configuration';
+        return this.http.get<any>(url);
+    }
+
 }
\ 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 20c27fb..3c1bbfe 100644
--- a/src/app/edit-attestations/edit-attestations.component.html
+++ b/src/app/edit-attestations/edit-attestations.component.html
@@ -72,7 +72,7 @@
         </tr>
       </tbody>
     </table>
-    
+
     <!--IdProvider-Discovery-->
     <div *ngIf="isExperimental()">
       <div *ngIf="!newIdProviderDiscovered()" class="input-group my-2 
col-lg-4">
@@ -94,13 +94,20 @@
         <span class="fa fa-openid"></span> Link account
       </button>
       <!--Link account-->
-      <button *ngIf="newIdProviderDiscovered() && !loggedIn()" class="btn 
btn-primary mb-4 fhg-link"
-        (click)="loginFhgAccount()">
-        <span class="fa fa-user"></span> Grant Access to {{newIdProvider.name}}
-      </button>
-      <button *ngIf="newIdProviderDiscovered() && !loggedIn()" class="btn 
btn-primary mb-4 fhg-link" (click)="cancelLinking()">
-        Cancel Linking
-      </button>
+      <div *ngIf="newIdProviderDiscovered() && !loggedIn()" class="card mb-3 
px-2">
+          <div class="card-header mx-n2">Scopes</div>
+          <div *ngFor="let scope of scopes" class="form-check mx-2">
+            <input type="checkbox" class="form-check-input" id="scopes" 
[(ngModel)]="scope.chosen">
+            <label class="form-check-label" 
for="scope.chosen">{{scope.scope}}</label>
+          </div>
+        <button class="btn btn-primary mb-1 mt-2 fhg-link" 
(click)="loginFhgAccount()">
+          <span class="fa fa-user"></span> Grant Access to 
{{newIdProvider.name}}
+        </button>
+        <button class="btn btn-primary mb-1 fhg-link" 
(click)="cancelLinking()">
+          Cancel Linking
+        </button>
+      </div>
+
     </div>
     <!-- Attestation creation warning -->
     <div
diff --git a/src/app/edit-attestations/edit-attestations.component.ts 
b/src/app/edit-attestations/edit-attestations.component.ts
index b1a6b51..470f2d2 100644
--- a/src/app/edit-attestations/edit-attestations.component.ts
+++ b/src/app/edit-attestations/edit-attestations.component.ts
@@ -10,6 +10,7 @@ import { AttestationService } from '../attestation.service';
 import { OAuthService } from 'angular-oauth2-oidc';
 import { IdProvider } from '../idProvider';
 import { LoginOptions } from 'angular-oauth2-oidc';
+import { Scope } from '../scope';
 
 @Component({
   selector: 'app-edit-attestations',
@@ -25,6 +26,7 @@ export class EditAttestationsComponent implements OnInit {
   webfingerEmail: string;
   emailNotFoundAlertClosed: boolean;
   errorMassage: string;
+  scopes: Scope[];
 
   constructor(private reclaimService: ReclaimService,
               private identityService: IdentityService,
@@ -40,14 +42,14 @@ export class EditAttestationsComponent implements OnInit {
     this.webfingerEmail = '';
     this.emailNotFoundAlertClosed = true;
     this.errorMassage = '';
+    this.scopes = [];
     this.loadIdProviderFromLocalStorage();
     this.attestations = [];
     if (this.newIdProvider.url !== ''){
       const loginOptions: LoginOptions = {
         customHashFragment: "?code="+localStorage.getItem("attestationCode") + 
"&state=" + localStorage.getItem("attestationState") + "&session_state="+ 
localStorage.getItem("attestationSession_State"),
       }
-      console.log(loginOptions.customHashFragment);
-      
this.oauthService.configure(this.attestationService.getOauthConfig(this.newIdProvider));
+      this.configureOauthService();
       if (!localStorage.getItem("attestationCode")){
         this.oauthService.loadDiscoveryDocumentAndTryLogin();
       }
@@ -253,7 +255,7 @@ export class EditAttestationsComponent implements OnInit {
 
 
   //Webfinger
-  
+
   discoverIdProvider() {
     if (this.webfingerEmail == ''){
       return;
@@ -268,6 +270,7 @@ export class EditAttestationsComponent implements OnInit {
        localStorage.setItem('newIdProviderLogoutURL', 
this.newIdProvider.logoutURL);
       console.log(this.newIdProvider.url);
       this.webfingerEmail == '';
+      this.getScopes();
     },
     error => {
       if (error.status == 404){
@@ -283,6 +286,20 @@ export class EditAttestationsComponent implements OnInit {
     });
   }
 
+  getScopes(){
+    this.configureOauthService();
+    
this.attestationService.getDiscoveryDocument(this.oauthService.issuer).subscribe(openidConfig
 => {
+      openidConfig["scopes_supported"].forEach(scope => {
+        const scopeInterface: Scope = {
+          scope: scope,
+          chosen: true,
+        }
+        this.scopes.push(scopeInterface)
+      });
+      console.log(this.scopes);
+      });  
+  }
+
   newIdProviderDiscovered(){
     if (this.newIdProvider.url == ''){
       return false;
@@ -298,9 +315,12 @@ export class EditAttestationsComponent implements OnInit {
   }
 
   loginFhgAccount(){
+    this.oauthService.loadDiscoveryDocumentAndLogin();
+  }
+
+  configureOauthService(){
     var authCodeFlowConfig = 
this.attestationService.getOauthConfig(this.newIdProvider);
     this.oauthService.configure(authCodeFlowConfig);
-    this.oauthService.loadDiscoveryDocumentAndLogin();
   }
 
   cancelLinking(){
@@ -313,8 +333,6 @@ export class EditAttestationsComponent implements OnInit {
     return ((undefined !== exp) && ("" !== exp));
   }
 
-  
-
 
 
 }
diff --git a/src/app/scope.ts b/src/app/scope.ts
new file mode 100644
index 0000000..a6a377c
--- /dev/null
+++ b/src/app/scope.ts
@@ -0,0 +1,4 @@
+export interface Scope{
+    scope: string,
+    chosen: boolean,
+}
\ 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]