Browse Source

Relax the client authentication policy to allow public applications to use the refresh token grant

pull/41/head
Kévin Chalet 11 years ago
parent
commit
b044568563
  1. 19
      src/OpenIddict.Core/OpenIddictProvider.cs

19
src/OpenIddict.Core/OpenIddictProvider.cs

@ -82,19 +82,12 @@ namespace OpenIddict {
} }
public override async Task ValidateClientAuthentication([NotNull] ValidateClientAuthenticationContext context) { public override async Task ValidateClientAuthentication([NotNull] ValidateClientAuthenticationContext context) {
// Note: in pure OAuth2, client authentication is not required for non-confidential client applications like mobile apps // Note: though required by the OpenID Connect specification for the refresh token grant,
// but OpenIddict uses a stricter policy that makes client authentication mandatory when using the refresh token grant type, // client authentication is not mandatory for non-confidential client applications in OAuth2.
// as required by the OpenID Connect specification: http://openid.net/specs/openid-connect-core-1_0.html#RefreshingAccessToken // To avoid breaking OAuth2 scenarios, OpenIddict uses a relaxed policy that allows
// When client_id and/or client_secret is/are missing, an error is returned to the client application. // public applications to use the refresh token grant without having to authenticate.
if (context.Request.IsRefreshTokenGrantType() && (string.IsNullOrEmpty(context.ClientId) || // See http://openid.net/specs/openid-connect-core-1_0.html#RefreshingAccessToken
string.IsNullOrEmpty(context.ClientSecret))) { // and https://tools.ietf.org/html/rfc6749#section-6 for more information.
context.Reject(
error: OpenIdConnectConstants.Errors.InvalidClient,
description: "Missing credentials: ensure that your credentials were correctly " +
"flowed in the request body or in the authorization header.");
return;
}
// Skip client authentication if the client identifier is missing. // Skip client authentication if the client identifier is missing.
// Note: ASOS will automatically ensure that the calling application // Note: ASOS will automatically ensure that the calling application

Loading…
Cancel
Save