public AuthorizationViewModel(string challenge, string pollUrl, string resolutionUrl, PresentationRequest presentationRequest = null) { Challenge = challenge; PollUrl = pollUrl; ResolutionUrl = resolutionUrl; PresentationRequest = presentationRequest; Interval = 2000; }
private async Task <List <Claim> > GetClaims() { _logger.LogDebug($"Creating Claims list for presentation record id : {_session.PresentationRecordId}"); var claims = new List <Claim> { new Claim(IdentityConstants.PresentationRequestConfigIDParamName, _session.PresentationRecordId), new Claim(IdentityConstants.AuthenticationContextReferenceIdentityTokenKey, IdentityConstants.VCAuthnScopeName) }; var presentationConfig = await _presentationConfigurationService.GetAsync(_session.PresentationRecordId); if (_session.RequestParameters.ContainsKey(IdentityConstants.NonceParameterName)) { claims.Add(new Claim(IdentityConstants.NonceParameterName, _session.RequestParameters[IdentityConstants.NonceParameterName])); } PresentationRequest presentationRequest = JsonConvert.DeserializeObject <PresentationRequest>(_session.PresentationRequest); foreach (var requestedAttr in presentationRequest.RequestedAttributes) { if (_session.Presentation.RequestedProof.RevealedAttributes.ContainsKey(requestedAttr.Key)) { _logger.LogDebug("Processing revealed attributes"); claims.Add(new Claim(requestedAttr.Value.Name, _session.Presentation.RequestedProof.RevealedAttributes[requestedAttr.Key].Raw)); if (!string.IsNullOrEmpty(presentationConfig.SubjectIdentifier) && string.Equals(requestedAttr.Value.Name, presentationConfig.SubjectIdentifier, StringComparison.InvariantCultureIgnoreCase)) { claims.Add(new Claim(IdentityConstants.SubjectIdentityTokenKey, _session.Presentation.RequestedProof.RevealedAttributes[requestedAttr.Key].Raw)); } } else if (_session.Presentation.RequestedProof.RevealedAttributesGroups.ContainsKey(requestedAttr.Key)) { _logger.LogDebug("Processing revealed attributes groups"); foreach (string name in requestedAttr.Value.Names) { claims.Add(new Claim(name, _session.Presentation.RequestedProof.RevealedAttributesGroups[requestedAttr.Key].Values[name].Raw)); if (!string.IsNullOrEmpty(presentationConfig.SubjectIdentifier) && string.Equals(name, presentationConfig.SubjectIdentifier, StringComparison.InvariantCultureIgnoreCase)) { claims.Add(new Claim(IdentityConstants.SubjectIdentityTokenKey, _session.Presentation.RequestedProof.RevealedAttributesGroups[requestedAttr.Key].Values[name].Raw)); } } } } if (!claims.Any(_ => _.Type == IdentityConstants.SubjectIdentityTokenKey)) { claims.Add(new Claim(IdentityConstants.SubjectIdentityTokenKey, Guid.NewGuid().ToString())); } // Add "issued at" standard OIDC claim - see https://tools.ietf.org/html/rfc7519#section-4 claims.Add(new Claim(IdentityConstants.OIDCTokenIssuedAt, DateTimeOffset.Now.ToUnixTimeSeconds().ToString(), System.Security.Claims.ClaimValueTypes.Integer)); _logger.LogDebug($"Claims list created for presentation record id : {_session.PresentationRecordId}, values : {claims.ToJson()}"); return(claims); }
private PresentationRequest BuildPresentationRequest(PresentationRecord record, WalletPublicDid acapyPublicDid) { record.Configuration.Nonce = $"0{Guid.NewGuid().ToString("N")}"; var request = new PresentationRequest { Id = Guid.NewGuid().ToString(), Request = record.Configuration, Service = new ServiceDecorator { RecipientKeys = new List <string> { acapyPublicDid.Verkey }, ServiceEndpoint = _acapyClient.GetServicePublicUrl() } }; return(request); }
private async Task <List <Claim> > GetClaims() { _logger.LogDebug($"Creating Claims list for presentation record id : {_session.PresentationRecordId}"); var claims = new List <Claim> { new Claim(IdentityConstants.PresentationRequestConfigIDParamName, _session.PresentationRecordId), new Claim(IdentityConstants.AuthenticationContextReferenceIdentityTokenKey, IdentityConstants.VCAuthnScopeName) }; var presentationConfig = await _presentationConfigurationService.GetAsync(_session.PresentationRecordId); if (_session.RequestParameters.ContainsKey(IdentityConstants.NonceParameterName)) { claims.Add(new Claim(IdentityConstants.NonceParameterName, _session.RequestParameters[IdentityConstants.NonceParameterName])); } PresentationRequest presentationRequest = JsonConvert.DeserializeObject <PresentationRequest>(_session.PresentationRequest); foreach (var requestedAttr in presentationRequest.RequestedAttributes) { if (_session.Presentation.RequestedProof.RevealedAttributes.ContainsKey(requestedAttr.Key)) { claims.Add(new Claim(requestedAttr.Value.Name, _session.Presentation.RequestedProof.RevealedAttributes[requestedAttr.Key].Raw)); if (!string.IsNullOrEmpty(presentationConfig.SubjectIdentifier) && string.Equals(requestedAttr.Value.Name, presentationConfig.SubjectIdentifier, StringComparison.InvariantCultureIgnoreCase)) { claims.Add(new Claim(IdentityConstants.SubjectIdentityTokenKey, _session.Presentation.RequestedProof.RevealedAttributes[requestedAttr.Key].Raw)); } } } if (!claims.Any(_ => _.Type == IdentityConstants.SubjectIdentityTokenKey)) { claims.Add(new Claim(IdentityConstants.SubjectIdentityTokenKey, Guid.NewGuid().ToString())); } _logger.LogDebug($"Claims list created for presentation record id : {_session.PresentationRecordId}, values : {claims.ToJson()}"); return(claims); }