-
Notifications
You must be signed in to change notification settings - Fork 189
feat: Adds Token Vault support #1064
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| using Microsoft.IdentityModel.Tokens; | ||
|
|
||
| namespace Auth0.AuthenticationApi.Models; | ||
|
|
||
| /// <summary> | ||
| /// Represents a request to exchange an Auth0 token for an access token issued by one of | ||
| /// Auth0's federated connections (Token Vault), using the Auth0 token-exchange grant | ||
| /// <c>urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token</c>. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The client must be a private client. Today the subject token must be an Auth0 refresh | ||
| /// token (<see cref="TokenType.RefreshToken"/>); support for access-token subjects is | ||
| /// planned by Auth0. | ||
| /// </remarks> | ||
| public class FederatedConnectionAccessTokenRequest : IClientAuthentication | ||
| { | ||
| /// <summary> | ||
| /// The Auth0 token being exchanged. Currently this must be a valid Auth0 refresh token. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doc says the subject token must be an Auth0 The class remark on line 11 and the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 5b53c29 |
||
| /// Required. | ||
| /// </summary> | ||
| public string SubjectToken { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// An identifier that indicates the type of <see cref="SubjectToken"/>, as a URN. | ||
| /// Currently only <see cref="TokenType.RefreshToken"/> is accepted. Required. | ||
| /// </summary> | ||
| public string SubjectTokenType { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The federated connection to obtain the access token for (for example | ||
| /// <c>google-oauth2</c>). Required. | ||
| /// </summary> | ||
| public string Connection { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Optional user ID of the current user within the IdP named by <see cref="Connection"/>. | ||
| /// For example, if the connection is <c>google-oauth2</c>, this is the Google user ID. | ||
| /// </summary> | ||
| public string LoginHint { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Client ID of the application. | ||
| /// </summary> | ||
| public string ClientId { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Client Secret of the application. | ||
| /// </summary> | ||
| public string ClientSecret { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Security Key to use with Client Assertion. | ||
| /// </summary> | ||
| public SecurityKey ClientAssertionSecurityKey { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Algorithm for the Security Key to use with Client Assertion. | ||
| /// </summary> | ||
| public string ClientAssertionSecurityKeyAlgorithm { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// What <see cref="JwtSignatureAlgorithm"/> is used to verify the signature of Id Tokens. | ||
| /// </summary> | ||
| public JwtSignatureAlgorithm SigningAlgorithm { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Optional nonce to validate against the nonce claim in a returned ID token. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// When set, the nonce claim in the returned ID token must exactly match this value. | ||
| /// Leave null (the default) to skip nonce validation. | ||
| /// </remarks> | ||
| public string? Nonce { get; set; } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,4 +30,14 @@ public static class TokenType | |
| /// Indicates that the token is an Auth0 Session Transfer Token: <c>urn:auth0:params:oauth:token-type:session_transfer_token</c>. | ||
| /// </summary> | ||
| public const string SessionTransferToken = "urn:auth0:params:oauth:token-type:session_transfer_token"; | ||
|
|
||
| /// <summary> | ||
| /// Indicates that the token is an OAuth 2.0 refresh token: <c>urn:ietf:params:oauth:token-type:refresh_token</c>. | ||
| /// </summary> | ||
| public const string RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This If refresh token subjects are genuinely supported, can we add a test that uses this? Otherwise I would drop it so we do not signal a path that does not work. Low priority either way.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 5b53c29 |
||
|
|
||
| /// <summary> | ||
| /// Indicates that the token is an Auth0 federated connection access token: <c>http://auth0.com/oauth/token-type/federated-connection-access-token</c>. | ||
| /// </summary> | ||
| public const string FederatedConnectionAccessToken = "http://auth0.com/oauth/token-type/federated-connection-access-token"; | ||
| } | ||
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.
SubjectTokenandSubjectTokenTypeare both required but we add them to the body with no check. We already throw a clearArgumentExceptionfor a missingConnectiona few lines up, so it feels odd to let these two through and get back an opaque 400 from the server.Can we add the same kind of early null or empty guard for
SubjectTokenandSubjectTokenType?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.
Addressed in 5b53c29
Added validation