@@ -78,10 +78,18 @@ var ErrorInvalidNonce = errors.New("invalid_nonce")
7878
7979// Actual implementation of the verfifier functionality
8080
81+ // Verifier QR Information
82+ type QRLoginInfo struct {
83+ QR string
84+ ExpireAt time.Time
85+ TotalDuration int
86+ AuthenticationRequest string
87+ }
88+
8189// verifier interface
8290type Verifier interface {
8391 ReturnLoginQR (host string , protocol string , callback string , sessionId string , clientId string , nonce string , requestMode string ) (qr string , err error )
84- ReturnLoginQRV2 (host string , protocol string , callback string , sessionId string , clientId string , scope string , nonce string , requestMode string ) (qr string , err error )
92+ ReturnLoginQRV2 (host string , protocol string , callback string , sessionId string , clientId string , scope string , nonce string , requestMode string ) (qrLoginInfo QRLoginInfo , err error )
8593 StartSiopFlow (host string , protocol string , callback string , state string , clientId string , nonce string , requestMode string ) (connectionString string , err error )
8694 StartSameDeviceFlow (host string , protocol string , sessionId string , redirectPath string , clientId string , nonce string , requestMode string , scope string , requestProtocol string ) (authenticationRequest string , err error )
8795 GetToken (authorizationCode string , redirectUri string , validated bool ) (jwtString string , expiration int64 , err error )
@@ -136,6 +144,8 @@ type CredentialVerifier struct {
136144 verifierConfig configModel.Verifier
137145 // JWT token expiration time in minutes
138146 jwtExpiration time.Duration
147+ // Session duration in seconds
148+ sessionDuration time.Duration
139149}
140150
141151// allow singleton access to the verifier
@@ -358,6 +368,7 @@ func InitVerifier(config *configModel.Configuration) (err error) {
358368 verifierConfig .ClientIdentification ,
359369 * verifierConfig ,
360370 time .Duration (verifierConfig .JwtExpiration ) * time .Minute ,
371+ time .Duration (verifierConfig .SessionExpiry ),
361372 }
362373
363374 logging .Log ().Debug ("Successfully initalized the verifier" )
@@ -395,29 +406,36 @@ func (v *CredentialVerifier) ReturnLoginQR(host string, protocol string, callbac
395406/**
396407* Initializes the cross-device login flow and returns all neccessary information as a qr-code
397408**/
398- func (v * CredentialVerifier ) ReturnLoginQRV2 (host string , protocol string , redircetUri string , sessionId string , clientId string , scope string , nonce string , requestMode string ) (qr string , err error ) {
409+ func (v * CredentialVerifier ) ReturnLoginQRV2 (host string , protocol string , redircetUri string , sessionId string , clientId string , scope string , nonce string , requestMode string ) (qrInfo QRLoginInfo , err error ) {
399410
400411 for _ , v := range v .supportedRequestModes {
401412 logging .Log ().Warnf ("Supported: %s" , v )
402413 }
403414
404415 if ! slices .Contains (v .supportedRequestModes , requestMode ) {
405416 logging .Log ().Infof ("QR with mode %s was requested, but only %v is supported." , requestMode , v .supportedRequestModes )
406- return qr , ErrorUnsupportedRequestMode
417+ return qrInfo , ErrorUnsupportedRequestMode
407418 }
408419
409420 logging .Log ().Debugf ("Generate a login qr for %s." , redircetUri )
410421 authenticationRequest , err := v .initOid4VPCrossDevice (host , protocol , redircetUri , sessionId , clientId , scope , nonce , requestMode )
411422
412423 if err != nil {
413- return qr , err
424+ return qrInfo , err
414425 }
415426
416427 png , err := qrcode .Encode (authenticationRequest , qrcode .Medium , 256 )
417428 base64Img := base64 .StdEncoding .EncodeToString (png )
418429 base64Img = "data:image/png;base64," + base64Img
419430
420- return base64Img , err
431+ _ , expireAt , _ := v .sessionCache .GetWithExpiration (sessionId )
432+ qrInfo = QRLoginInfo {
433+ QR : base64Img ,
434+ ExpireAt : expireAt ,
435+ TotalDuration : int (v .sessionDuration ),
436+ AuthenticationRequest : authenticationRequest ,
437+ }
438+ return qrInfo , err
421439}
422440
423441/**
0 commit comments