gnunet-svn
[Top][All Lists]
Advanced

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

[reclaim-ui] 196/459: issuer discoverable


From: gnunet
Subject: [reclaim-ui] 196/459: issuer discoverable
Date: Fri, 11 Jun 2021 23:24:48 +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 26fc4d0eccd6b348dc32bd7144c209e51daac4b2
Author: anna wimbauer <anna.wibauer@gmx.de>
AuthorDate: Mon May 18 13:52:04 2020 +0200

    issuer discoverable
---
 src/app/app.module.ts                              |  2 ++
 src/app/edit-identity/edit-identity.component.html | 17 +++++++++++
 src/app/edit-identity/edit-identity.component.ts   | 33 ++++++++++++++++++++--
 src/app/id-provider.ts                             | 11 ++++++++
 src/app/webfinger.service.ts                       | 22 +++++++++++++++
 5 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 13fe6db..6a2b03a 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -15,6 +15,7 @@ import { ModalComponent } from './modal.component';
 import { ModalService } from './modal.service';
 import { SearchPipe } from './search.pipe';
 import { OpenIdService } from './open-id.service';
+import { WebfingerService } from './webfinger.service'
 import { NewIdentityComponent } from './new-identity/new-identity.component';
 import { EditIdentityComponent } from 
'./edit-identity/edit-identity.component';
 import { AuthorizationRequestComponent } from 
'./authorization-request/authorization-request.component';
@@ -48,6 +49,7 @@ import { EditAttestationsComponent } from 
'./edit-attestations/edit-attestations
     GnsService,
     OpenIdService,
     ConfigService,
+    WebfingerService,
     {
       provide: APP_INITIALIZER,
       useFactory: (config: ConfigService) => () => config.load(),
diff --git a/src/app/edit-identity/edit-identity.component.html 
b/src/app/edit-identity/edit-identity.component.html
index b1d108d..beeedf5 100644
--- a/src/app/edit-identity/edit-identity.component.html
+++ b/src/app/edit-identity/edit-identity.component.html
@@ -141,9 +141,26 @@
         <li>IDs and values may not be empty!</li>
       </ul>
     </div>
+
+    <div class="input-group my-2 col-lg-4">
+      <div class="input-group-prepend">
+        <span class="input-group-text">@</span>
+      </div>
+      <input placeholder="E-Mail Adress" class="form-control"  
[(ngModel)]="webfingerEmail">
+    </div>
+    <!--Issuer Discovery Warning-->
+    <div *ngIf="!isValidEmailforDiscovery()" class="alert alert-primary 
alert-dismissible fade show" role="alert">
+      <span class="fa fa-warning"></span> This is not a valid e-mail adress
+    </div>
+    <!--Email not found Warning-->
+    <div *ngIf="!emailNotFoundAlertClosed" class="alert alert-danger 
alert-dismissible fade show my-2" role="alert">
+      <span class="fa fa-warning"></span> No account found with email: 
{{webfingerEmail}}
+    </div>
     <button *ngIf="isExperimental()" class="btn btn-primary mb-4 fhg-link" 
(click)="getFhGAttestation()">
       <span class="fa fa-user"></span> Link Fraunhofer Account
     </button>
+
+    
     <hr/>
 
     <!-- Edit card buttons -->
diff --git a/src/app/edit-identity/edit-identity.component.ts 
b/src/app/edit-identity/edit-identity.component.ts
index 1f219c5..5a71fe4 100644
--- a/src/app/edit-identity/edit-identity.component.ts
+++ b/src/app/edit-identity/edit-identity.component.ts
@@ -10,6 +10,8 @@ import { Attestation } from '../attestation';
 import { IdentityService } from '../identity.service';
 import { finalize } from 'rxjs/operators';
 import { from, forkJoin, EMPTY } from 'rxjs';
+import {WebfingerService} from '../webfinger.service';
+import { IdProvider } from '../id-provider'
 
 @Component({
   selector: 'app-edit-identity',
@@ -29,6 +31,9 @@ export class EditIdentityComponent implements OnInit {
   missingAttested: Attribute[];
   requestedAttested: Attribute[];
   optionalAttested: Attribute[];
+  webfingerEmail: string;
+  idProvider: IdProvider;
+  emailNotFoundAlertClosed: boolean;
 
   constructor(private reclaimService: ReclaimService,
               private identityService: IdentityService,
@@ -36,13 +41,16 @@ export class EditIdentityComponent implements OnInit {
               private oidcService: OpenIdService,
               private namestoreService: NamestoreService,
               private activatedRoute: ActivatedRoute,
-              private router: Router) { }
+              private router: Router,
+              private webfingerService: WebfingerService) { }
 
   ngOnInit() {
     this.attributes = [];
     this.attestations = [];
     this.optionalAttested = [];
     this.attestationValues = {};
+    this.webfingerEmail = '';
+    this.emailNotFoundAlertClosed = true;
     this.identity = new Identity('','');
     this.newAttribute = new Attribute('', '', '', '', 'STRING', '');
     this.newAttested = new Attribute('', '', '', '', 'STRING', '');
@@ -610,8 +618,29 @@ export class EditIdentityComponent implements OnInit {
   }
 
   getFhGAttestation() {
+    if (this.webfingerEmail == ''){
+      return;
+    }
     localStorage.setItem('userForAttestation', this.identity.name);
-    window.location.href = 
"http://localhost:4567/authorize?redirect_uri=http%3A%2F%2Flocalhost:4200%2Findex.html&client_id=reclaimid&response_type=code&scopes=openid";;
+    this.isValidEmailforDiscovery();
+    this.webfingerService.getLink(this.webfingerEmail).subscribe (idProvider 
=> {
+      this.idProvider = idProvider;
+    },
+    error => {
+      if (error.status == 404){
+        this.emailNotFoundAlertClosed = false;
+        setTimeout(() => this.emailNotFoundAlertClosed = true, 20000);
+      }
+      console.log (error);
+    });
+    //window.location.href = 
"http://localhost:4567/authorize?redirect_uri=http%3A%2F%2Flocalhost:4200%2Findex.html&client_id=reclaimid&response_type=code&scopes=openid";;
+  }
+
+  isValidEmailforDiscovery(){
+    if (!this.webfingerEmail.includes('@') && this.webfingerEmail != ''){
+      return false;
+    }
+    return true;
   }
 
   setExperimental(set) {
diff --git a/src/app/id-provider.ts b/src/app/id-provider.ts
new file mode 100644
index 0000000..77912e1
--- /dev/null
+++ b/src/app/id-provider.ts
@@ -0,0 +1,11 @@
+export interface IdProvider{
+    subject: string;
+    properties: {
+        "http://schema.org/name": string; 
+    }
+    links: {
+        rel: string;
+        href: string;
+    }
+
+}
\ No newline at end of file
diff --git a/src/app/webfinger.service.ts b/src/app/webfinger.service.ts
new file mode 100644
index 0000000..94874af
--- /dev/null
+++ b/src/app/webfinger.service.ts
@@ -0,0 +1,22 @@
+import { HttpClient, HttpHeaders} from '@angular/common/http';
+import { Injectable } from '@angular/core'
+import { Observable } from 'rxjs';
+import { IdProvider } from './id-provider'
+
+// https://github.com/d-koppenhagen/webfinger
+
+@Injectable()
+export class WebfingerService {
+
+    webfingerEndpoint = 'http://localhost:4567'
+
+    constructor(private http: HttpClient) {
+    }
+
+    
+ 
+    getLink (email: string): Observable<IdProvider>{
+        return this.http.get<IdProvider>(this.webfingerEndpoint + 
'/.well-known/webfinger?resource=acct:' + email);
+    }
+
+}
\ 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]