@@ -227,6 +227,8 @@ type loginSession struct {
227227 requestObject string
228228 // inidicates if the cross device session is v1 or v2
229229 version int
230+ // scope requested for the session
231+ scope string
230232}
231233
232234// struct to represent a token, accessible through the token endpoint
@@ -435,7 +437,7 @@ func (v *CredentialVerifier) StartSameDeviceFlow(host string, protocol string, s
435437 nonce = v .nonceGenerator .GenerateNonce ()
436438 }
437439
438- loginSession := loginSession {callback : fmt .Sprintf ("%s://%s%s" , protocol , host , redirectPath ), sessionId : state , nonce : nonce , clientId : clientId , version : SAME_DEVICE }
440+ loginSession := loginSession {callback : fmt .Sprintf ("%s://%s%s" , protocol , host , redirectPath ), sessionId : state , nonce : nonce , clientId : clientId , version : SAME_DEVICE , scope : scope }
439441 err = v .sessionCache .Add (state , loginSession , cache .DefaultExpiration )
440442 if err != nil {
441443 logging .Log ().Warnf ("Was not able to store the login session %s in cache. Err: %v" , logging .PrettyPrintObject (loginSession ), err )
@@ -797,7 +799,7 @@ func (v *CredentialVerifier) AuthenticationResponse(state string, verifiablePres
797799
798800 for _ , credential := range verifiablePresentation .Credentials () {
799801
800- verificationContext , err := v .getTrustRegistriesValidationContext (loginSession .clientId , credential .Contents ().Types )
802+ verificationContext , err := v .getTrustRegistriesValidationContext (loginSession .clientId , credential .Contents ().Types , loginSession . scope )
801803 if err != nil {
802804 logging .Log ().Warnf ("Was not able to create a valid verification context. Credential will be rejected. Err: %v" , err )
803805 return sameDevice , ErrorVerficationContextSetup
@@ -837,7 +839,7 @@ func (v *CredentialVerifier) AuthenticationResponse(state string, verifiablePres
837839 toBeIncluded = append (toBeIncluded , credential .ToRawJSON ())
838840 }
839841
840- flatClaims , _ := v .credentialsConfig .GetFlatClaims (loginSession .clientId , configModel . SERVICE_DEFAULT_SCOPE )
842+ flatClaims , _ := v .credentialsConfig .GetFlatClaims (loginSession .clientId , loginSession . scope )
841843 token , err := v .generateJWT (toBeIncluded , verifiablePresentation .Holder , hostname , flatClaims )
842844 if err != nil {
843845 logging .Log ().Warnf ("Was not able to create a jwt for %s. Err: %v" , state , err )
@@ -949,17 +951,18 @@ func (v *CredentialVerifier) getHolderValidationContext(clientId string, scope s
949951 return validationContexts , err
950952}
951953
952- func (v * CredentialVerifier ) getTrustRegistriesValidationContext (clientId string , credentialTypes []string ) (verificationContext TrustRegistriesValidationContext , err error ) {
954+ func (v * CredentialVerifier ) getTrustRegistriesValidationContext (clientId string , credentialTypes []string , scope string ) (verificationContext TrustRegistriesValidationContext , err error ) {
955+ logging .Log ().Debugf ("Create trust registry validation context for client '%s', scope '%s' and credential types %s" , clientId , scope , credentialTypes )
953956 trustedIssuersLists := map [string ][]string {}
954957 trustedParticipantsRegistries := map [string ][]configModel.TrustedParticipantsList {}
955958
956959 for _ , credentialType := range credentialTypes {
957- issuersLists , err := v .credentialsConfig .GetTrustedIssuersLists (clientId , configModel . SERVICE_DEFAULT_SCOPE , credentialType )
960+ issuersLists , err := v .credentialsConfig .GetTrustedIssuersLists (clientId , scope , credentialType )
958961 if err != nil {
959962 logging .Log ().Warnf ("Was not able to get valid trusted-issuers-lists for client %s and type %s. Err: %v" , clientId , credentialType , err )
960963 return verificationContext , err
961964 }
962- participantsLists , err := v .credentialsConfig .GetTrustedParticipantLists (clientId , configModel . SERVICE_DEFAULT_SCOPE , credentialType )
965+ participantsLists , err := v .credentialsConfig .GetTrustedParticipantLists (clientId , scope , credentialType )
963966 if err != nil {
964967 logging .Log ().Warnf ("Was not able to get valid trusted-pariticpants-registries for client %s and type %s. Err: %v" , clientId , credentialType , err )
965968 return verificationContext , err
@@ -1047,7 +1050,7 @@ func verifyChain(vcs []*verifiable.Credential) (bool, error) {
10471050// intialize the OID4VP cross device flow
10481051func (v * CredentialVerifier ) initOid4VPCrossDevice (host string , protocol string , redirectUri string , state string , clientId string , scope string , nonce string , requestMode string ) (authenticationRequest string , err error ) {
10491052
1050- loginSession := loginSession {redirectUri , state , nonce , clientId , "" , CROSS_DEVICE_V2 }
1053+ loginSession := loginSession {redirectUri , state , nonce , clientId , "" , CROSS_DEVICE_V2 , scope }
10511054 err = v .sessionCache .Add (state , loginSession , cache .DefaultExpiration )
10521055
10531056 if err != nil {
@@ -1066,7 +1069,7 @@ func (v *CredentialVerifier) initSiopFlow(host string, protocol string, callback
10661069 logging .Log ().Debugf ("No nonce provided, generate one." )
10671070 nonce = v .nonceGenerator .GenerateNonce ()
10681071 }
1069- loginSession := loginSession {callback , state , nonce , clientId , "" , CROSS_DEVICE_V1 }
1072+ loginSession := loginSession {callback , state , nonce , clientId , "" , CROSS_DEVICE_V1 , "" }
10701073 err = v .sessionCache .Add (state , loginSession , cache .DefaultExpiration )
10711074
10721075 if err != nil {
0 commit comments