From the documentation:
Interactive clients should use an authorization code-based flow. To
protect against code substitution, either hybrid flow or PKCE should
be used.
Thus the combination of PKCE and hybrid flow is not necessary and probably not useful.
If PKCE is available, this is the simpler solution to the problem.
PKCE is already the official recommendation for native applications
and SPAs - and with the release of ASP.NET Core 3 also by default
supported in the OpenID Connect handler as well.
So instead of using the hybrid flow, configure it as interactive ASP.NET Core MVC client.
new Client
{
ClientId = "mvc",
ClientSecrets = { new Secret("secret".Sha256()) },
AllowedGrantTypes = GrantTypes.Code,
RequireConsent = false,
RequirePkce = true,
// where to redirect to after login
RedirectUris = { "http://localhost:5002/signin-oidc" },
// where to redirect to after logout
PostLogoutRedirectUris = { "http://localhost:5002/signout-callback-oidc" },
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile
}
}
Where the mvc client has the expected configuration:
.AddOpenIdConnect("oidc", options =>
{
options.Authority = "http://localhost:5000";
options.RequireHttpsMetadata = false;
options.ClientId = "mvc";
options.ClientSecret = "secret";
options.ResponseType = "code";
options.SaveTokens = true;
});
I can also recommend this post from Brock Allen. This may answer your question about cookies. You can also check the post of Dominick Baier.
For information on how to use the refresh token please read my answer here.