Skip to content

Commit

Permalink
Make the issuer optional for sign-out operations when only one regist…
Browse files Browse the repository at this point in the history
…ration was added
  • Loading branch information
kevinchalet committed Sep 1, 2022
1 parent db9b549 commit 9cb8878
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/OpenIddict.Abstractions/OpenIddictResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 10 additions & 0 deletions src/OpenIddict.Client/OpenIddictClientHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4468,6 +4468,16 @@ public ValueTask HandleAsync(ProcessSignOutContext context)
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;
}
}
Expand Down

0 comments on commit 9cb8878

Please sign in to comment.