Skip to content
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

Fix various issues with the hybrid flow #11719

Merged
merged 1 commit into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,25 @@ public async Task<IActionResult> Edit(string id, string returnUrl = null)

var model = new EditOpenIdApplicationViewModel
{
AllowAuthorizationCodeFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode),
AllowAuthorizationCodeFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode) &&
await HasPermissionAsync(OpenIddictConstants.Permissions.ResponseTypes.Code),

AllowClientCredentialsFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.ClientCredentials),
AllowImplicitFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.Implicit),

// Note: the hybrid flow doesn't have a dedicated grant_type but is treated as a combination
// of both the authorization code and implicit grants. As such, to determine whether the hybrid
// flow is enabled, both the authorization code grant and the implicit grant MUST be enabled.
AllowHybridFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode) &&
await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.Implicit) &&
(await HasPermissionAsync(OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken) ||
await HasPermissionAsync(OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken) ||
await HasPermissionAsync(OpenIddictConstants.Permissions.ResponseTypes.CodeToken)),

AllowImplicitFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.Implicit) &&
(await HasPermissionAsync(OpenIddictConstants.Permissions.ResponseTypes.IdToken) ||
await HasPermissionAsync(OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken) ||
await HasPermissionAsync(OpenIddictConstants.Permissions.ResponseTypes.Token)),

AllowPasswordFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.Password),
AllowRefreshTokenFlow = await HasPermissionAsync(OpenIddictConstants.Permissions.GrantTypes.RefreshToken),
AllowLogoutEndpoint = await HasPermissionAsync(OpenIddictConstants.Permissions.Endpoints.Logout),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static async Task UpdateDescriptorFromSettings(this IOpenIdApplicationMan
descriptor.Permissions.Remove(OpenIddictConstants.Permissions.Endpoints.Logout);
}

if (model.AllowAuthorizationCodeFlow)
if (model.AllowAuthorizationCodeFlow || model.AllowHybridFlow)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode);
}
Expand All @@ -82,7 +82,7 @@ public static async Task UpdateDescriptorFromSettings(this IOpenIdApplicationMan
descriptor.Permissions.Remove(OpenIddictConstants.Permissions.GrantTypes.ClientCredentials);
}

if (model.AllowImplicitFlow)
if (model.AllowHybridFlow || model.AllowImplicitFlow)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Implicit);
}
Expand All @@ -109,7 +109,7 @@ public static async Task UpdateDescriptorFromSettings(this IOpenIdApplicationMan
descriptor.Permissions.Remove(OpenIddictConstants.Permissions.GrantTypes.RefreshToken);
}

if (model.AllowAuthorizationCodeFlow || model.AllowImplicitFlow)
if (model.AllowAuthorizationCodeFlow || model.AllowHybridFlow || model.AllowImplicitFlow)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Authorization);
}
Expand All @@ -118,8 +118,8 @@ public static async Task UpdateDescriptorFromSettings(this IOpenIdApplicationMan
descriptor.Permissions.Remove(OpenIddictConstants.Permissions.Endpoints.Authorization);
}

if (model.AllowAuthorizationCodeFlow || model.AllowClientCredentialsFlow ||
model.AllowPasswordFlow || model.AllowRefreshTokenFlow)
if (model.AllowAuthorizationCodeFlow || model.AllowHybridFlow ||
model.AllowClientCredentialsFlow || model.AllowPasswordFlow || model.AllowRefreshTokenFlow)
{
descriptor.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Token);
}
Expand Down