Browse Source

Make the issuer optional for sign-out operations when only one registration was added

pull/1514/head
Kévin Chalet 4 years ago
parent
commit
9cb88782f5
  1. 3
      src/OpenIddict.Abstractions/OpenIddictResources.resx
  2. 10
      src/OpenIddict.Client/OpenIddictClientHandlers.cs

3
src/OpenIddict.Abstractions/OpenIddictResources.resx

@ -1319,6 +1319,9 @@ Alternatively, you can disable the token storage feature by calling 'services.Ad
<data name="ID0340" xml:space="preserve">
<value>The endpoint type associated with the state token cannot be resolved.</value>
</data>
<data name="ID0341" xml:space="preserve">
<value>No issuer was specified in the sign-out properties. When multiple clients are registered, an issuer must be specified in the sign-out properties.</value>
</data>
<data name="ID2000" xml:space="preserve">
<value>The security token is missing.</value>
</data>

10
src/OpenIddict.Client/OpenIddictClientHandlers.cs

@ -4468,6 +4468,16 @@ public static partial class OpenIddictClientHandlers
throw new InvalidOperationException(SR.GetResourceString(SR.ID0024));
}
// If no issuer was explicitly attached and a single client is registered, use it.
// Otherwise, throw an exception to indicate that setting an explicit issuer
// is required when multiple clients are registered.
context.Issuer ??= context.Options.Registrations.Count switch
{
0 => throw new InvalidOperationException(SR.GetResourceString(SR.ID0304)),
1 => context.Options.Registrations[0].Issuer,
_ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0341))
};
return default;
}
}

Loading…
Cancel
Save