Skip to content

Commit

Permalink
feat: 7.2. Credential Request udpates
Browse files Browse the repository at this point in the history
Signed-off-by: Mykhailo Sizov <[email protected]>
  • Loading branch information
mishasizov-SK committed Feb 5, 2024
1 parent 9111e70 commit 6db1348
Show file tree
Hide file tree
Showing 16 changed files with 695 additions and 251 deletions.
353 changes: 177 additions & 176 deletions api/spec/openapi.gen.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/v1/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ components:
type: array
items:
type: string
credential_identifiers:
description: For Token response only. Array of strings, each uniquely identifying a Credential that can be issued using the Access Token returned in this response. Each of these Credentials corresponds to the same entry in the credential_configurations_supported Credential Issuer metadata but can contain different claim values or a different subset of claims within the claims set identified by that Credential type.
type: array
items:
type: string
required:
- type
CredentialDefinition:
Expand Down
14 changes: 14 additions & 0 deletions docs/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,10 @@ components:
properties:
tx_id:
type: string
authorization_details:
type: array
items:
$ref: './common.yaml#/components/schemas/AuthorizationDetails'
required:
- tx_id
StoreAuthorizationCodeRequest:
Expand Down Expand Up @@ -1416,6 +1420,11 @@ components:
type: array
items:
type: string
authorization_details:
description: REQUIRED when authorization_details parameter is used to request issuance of a certain Credential type as defined in Section 5.1.1. It MUST NOT be used otherwise. It is an array of objects, as defined in Section 7 of [RFC9396].
type: array
items:
$ref: './common.yaml#/components/schemas/AuthorizationDetails'
required:
- op_state
- scopes
Expand Down Expand Up @@ -1604,6 +1613,11 @@ components:
c_nonce_expires_in:
description: Integer denoting the lifetime in seconds of the c_nonce.
type: integer
authorization_details:
description: REQUIRED when authorization_details parameter is used to request issuance of a certain Credential type as defined in Section 5.1.1. It MUST NOT be used otherwise. It is an array of objects, as defined in Section 7 of [RFC9396].
type: array
items:
$ref: './common.yaml#/components/schemas/AuthorizationDetails'
required:
- access_token
- token_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (w *Wrapper) StoreAuthorizationCode(ctx context.Context, opState string, co
return w.svc.StoreAuthorizationCode(ctx, opState, code, flowData)
}

func (w *Wrapper) ExchangeAuthorizationCode(ctx context.Context, opState, clientID, clientAttestationType, clientAttestation string) (oidc4ci.TxID, error) {
func (w *Wrapper) ExchangeAuthorizationCode(ctx context.Context, opState, clientID, clientAttestationType, clientAttestation string) (*oidc4ci.ExchangeAuthorizationCodeResult, error) {
return w.svc.ExchangeAuthorizationCode(ctx, opState, clientID, clientAttestationType, clientAttestation)
}

Expand Down
54 changes: 30 additions & 24 deletions pkg/restapi/v1/common/openapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 23 additions & 6 deletions pkg/restapi/v1/issuer/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ func (c *Controller) ExchangeAuthorizationCodeRequest(ctx echo.Context) error {
return err
}

txID, err := c.oidc4ciService.ExchangeAuthorizationCode(ctx.Request().Context(),
exchangeAuthorizationCodeResult, err := c.oidc4ciService.ExchangeAuthorizationCode(ctx.Request().Context(),
body.OpState,
lo.FromPtr(body.ClientId),
lo.FromPtr(body.ClientAssertionType),
Expand All @@ -674,7 +674,17 @@ func (c *Controller) ExchangeAuthorizationCodeRequest(ctx echo.Context) error {
return util.WriteOutput(ctx)(nil, err)
}

return util.WriteOutput(ctx)(ExchangeAuthorizationCodeResponse{TxId: string(txID)}, nil)
var authorizationDetailsDTOList []common.AuthorizationDetails
if exchangeAuthorizationCodeResult.AuthorizationDetails != nil {
authorizationDetailsDTO := exchangeAuthorizationCodeResult.AuthorizationDetails.ToDTO()
authorizationDetailsDTOList = []common.AuthorizationDetails{authorizationDetailsDTO}
}

return util.WriteOutput(ctx)(
ExchangeAuthorizationCodeResponse{
AuthorizationDetails: lo.ToPtr(authorizationDetailsDTOList),
TxId: string(exchangeAuthorizationCodeResult.TxID),
}, nil)
}

// ValidatePreAuthorizedCodeRequest Validates authorization code and pin.
Expand All @@ -686,7 +696,7 @@ func (c *Controller) ValidatePreAuthorizedCodeRequest(ctx echo.Context) error {
return err
}

result, err := c.oidc4ciService.ValidatePreAuthorizedCodeRequest(ctx.Request().Context(),
transaction, err := c.oidc4ciService.ValidatePreAuthorizedCodeRequest(ctx.Request().Context(),
body.PreAuthorizedCode,
lo.FromPtr(body.UserPin),
lo.FromPtr(body.ClientId),
Expand All @@ -697,10 +707,17 @@ func (c *Controller) ValidatePreAuthorizedCodeRequest(ctx echo.Context) error {
return err
}

var authorizationDetailsDTOList []common.AuthorizationDetails
if transaction.AuthorizationDetails != nil {
authorizationDetailsDTO := transaction.AuthorizationDetails.ToDTO()
authorizationDetailsDTOList = []common.AuthorizationDetails{authorizationDetailsDTO}
}

return util.WriteOutput(ctx)(ValidatePreAuthorizedCodeResponse{
TxId: string(result.ID),
OpState: result.OpState,
Scopes: result.Scope,
AuthorizationDetails: lo.ToPtr(authorizationDetailsDTOList),
TxId: string(transaction.ID),
OpState: transaction.OpState,
Scopes: transaction.Scope,
}, nil)
}

Expand Down
Loading

0 comments on commit 6db1348

Please sign in to comment.