IdentityServer
IdentityServer copied to clipboard
Use the new C#9 record syntax for the client definition
Today when you define your client in code, the classes get quite long and unmaintainable. Often you have one definition for development and one for production that you need to keep in sync.
to avoid configuration drift, then using the C# 9 record syntax, you could then define them using code like this:
var devclient = new Client()
{
ClientId = "myclient",
ClientName = "My Client application",
RedirectUris =
{
"https://localhost:5001/signin-oidc",
},
ClientSecrets = new List<Secret> { new Secret { Value = "mydevsecret".Sha512() } },
PostLogoutRedirectUris =
{
"https://localhost:5001/signout-callback-oidc"
}
// ...
};
var prodclient = devclient with
{
ClientSecrets = new List<Secret> { new Secret { Value = "myprodsecret".Sha512() } },
RedirectUris = new List<string>() { "https://localhost:5001/signin-oidc" },
PostLogoutRedirectUris = new List<string>() {"https://production.com/signout-callback-oidc" }
};
Using the With syntax, you can now very cleanly override some of the settings with the rest is unchanged.
pretty neat I think 👍
That is indeed nice. We will consider that for v6. We don't want to do breaking changes right now...
I don't foresee this happening. Sorry.