-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat! auth code flow #2088
base: main
Are you sure you want to change the base?
feat! auth code flow #2088
Conversation
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
…esentation during issuance and batch issuance. This is a big change to OpenID4VCI in Credo, with the neccsary breaking changes since we first added it to the framework. Over time the spec has changed significantly, but also our understanding of the standards and protocols. **Authorization Code Flow** Credo now supports the authorization code flow, for both issuer and holder. An issuer can configure multiple authorization servers, and work with external authorization servers as well. The integration is based on OAuth2, with several extension specifications, mainly the OAuth2 JWT Access Token Profile, as well as Token Introspection (for opaque access tokens). Verification works out of the box, as longs as the authorization server has a `jwks_uri` configured. For Token Introspection it's also required to provide a `clientId` and `clientSecret` in the authorization server config. To use an external authorization server, the authorization server MUST include the `issuer_state` parameter from the credential offer in the access token. Otherwise it's not possible for Credo to correlate the authorization session to the offer session. The demo-openid contains an example with external authorization server, which can be used as reference. The Credo authorization server supports DPoP and PKCE. **Batch Issuance** The credential request to credential mapper has been updated to support multiple proofs, and also multiple credential instances. The client can now also handle batch issuance. **Presentation During Issuance** The presenation during issuance allows to request presentation using OID4VP before granting authorization for issuance of one or more credentials. This flow is automatically handled by the `resolveAuthorizationRequest` method on the oid4vci holder service. Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
🦋 Changeset detectedLatest commit: 35c2c96 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are quite some TODO's still, but I assume everything that should be fixed before merging will be fixed :). Good addition @TimoGlastra !!
@@ -0,0 +1,11 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use babel now?
- ✅ Issuing a credential without authorization (pre authorized). | ||
- ✅ Issuing a credenital with external authorization server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- ✅ Issuing a credential without authorization (pre authorized). | |
- ✅ Issuing a credenital with external authorization server | |
- ✅ Issuing a credential without authorization (pre authorized code flow). | |
- ✅ Issuing a credenital with external authorization server (authorized code flow). |
@@ -10,15 +10,19 @@ | |||
"license": "Apache-2.0", | |||
"scripts": { | |||
"issuer": "ts-node src/IssuerInquirer.ts", | |||
"provider": "tsx src/Provider.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just use ts-node or tsx for all of them, we don't need both
if (resolvedAuthorizationRequest.authorizationFlow === OpenId4VciAuthorizationFlow.PresentationDuringIssuance) { | ||
return { | ||
...resolvedAuthorizationRequest, | ||
authorizationFlow: `${OpenId4VciAuthorizationFlow.PresentationDuringIssuance}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authorizationFlow: `${OpenId4VciAuthorizationFlow.PresentationDuringIssuance}`, | |
authorizationFlow: OpenId4VciAuthorizationFlow.PresentationDuringIssuance, |
or
authorizationFlow: `${OpenId4VciAuthorizationFlow.PresentationDuringIssuance}`, | |
authorizationFlow: OpenId4VciAuthorizationFlow.PresentationDuringIssuance.toString(), |
} else { | ||
return { | ||
...resolvedAuthorizationRequest, | ||
authorizationFlow: `${OpenId4VciAuthorizationFlow.Oauth2Redirect}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@@ -39,6 +42,8 @@ export const matrrLaunchpadDraft11JwtVcJson = { | |||
{ | |||
id: 'b4c4cdf5-ccc9-4945-8c19-9334558653b2', | |||
format: 'ldp_vc', | |||
// FIXME: should we make this optional? Seems a lot of types break on this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// FIXME: should we make this optional? Seems a lot of types break on this | |
// TODO: should we make this optional? Seems a lot of types break on this |
Do we differentiate between FIXME and TODO? We should keep it conistent if they mean the same.
Might also be nice to have something like // TODO(oid): bla bla
next() | ||
}) | ||
|
||
// This one will be called for all errors that are thrown | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
contextRouter.use(async (_error: unknown, req: OpenId4VcIssuanceRequest, _res: unknown, next: any) => { | ||
contextRouter.use(async (_error: unknown, req: OpenId4VcIssuanceRequest, res: Response, next: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next is NextFunction
if I am not mistaken
OpenId4VciSignSdJwtCredential, | ||
OpenId4VciSignW3cCredential, | ||
OpenId4VciSignMdocCredential, | ||
OpenId4VciSignW3cCredentials, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as with the holder service file. Would really benefit from a split up in files and some helper functions to make it a lot easier to read.
/** | ||
* Whether presentation during issuance is required. | ||
*/ | ||
required: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this not be a boolean
?
url: fullRequestUrl, | ||
} as const | ||
|
||
// What error does this throw? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need a TODO?
See #2056