I am using the ASP.NET MVC 5 (4.5 or 4.8 version) application with Keycloak. I can see my login in Keycloak but it also gives an error. Please explain the error and the solution for the error. Any link to understand more about Keycloak would help.
Here is my startup.cs class:
[assembly: OwinStartup(typeof(keycloakapp1.Startup))]
namespace keycloakapp1
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Name of the persistent authentication middleware for lookup
const string persistentAuthType = "keycloak_cookies";
// --- Cookie Authentication Middleware - Persists user sessions between requests
var result = app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = persistentAuthType
});
app.SetDefaultSignInAsAuthenticationType(persistentAuthType); // Cookie is primary session store
// --- Keycloak Authentication Middleware - Connects to central Keycloak database
var result1 = app.UseKeycloakAuthentication(new KeycloakAuthenticationOptions
{
// App-Specific Settings
ClientId = "myclient", // *Required*
ClientSecret = "gxgRB2Z9BDIbxTOPw8mkeBFBUCp7wCOZ", // If using public authentication, delete this line
VirtualDirectory = "", // Set this if you use a virtual directory when deploying to IIS
// Instance-Specific Settings
Realm = "myrealm", // Don't change this unless told to do so
KeycloakUrl = "http://localhost:8080", // Enter your Keycloak URL here
// Template-Specific Settings
SignInAsAuthenticationType = persistentAuthType, // Sets the above cookie with the Keycloak data
AuthenticationType = "keycloakapp1", // Unique identifier for the auth middleware
DisableAudienceValidation = true,
AllowUnsignedTokens = true,
});
}
}
}
Getting IDX10500 error
IDX10500: Signature validation failed. Unable to resolve SecurityKeyIdentifier: 'SecurityKeyIdentifier
(
IsReadOnly = False,
Count = 1,
Clause[0] = System.IdentityModel.Tokens.NamedKeySecurityKeyIdentifierClause )
',
token: '{"alg":"HS256","typ":"JWT","kid":"f7b7d7a5-4c05-4278-b9e0-e496fc96cba7"}.
{"exp":1706119094,"iat":1706117294,"jti":"8ff74d97-8622-4e34-b715-d322a1c9f881","iss":"http://localhost:8080/realms/myrealm","aud":"http://localhost:8080/realms/myrealm","sub":"b656aadd-39cf-4f05-b3aa-7133bd8275d9","typ":"Refresh","azp":"myclient","session_state":"31947692-5bce-411d-93c2-5e20770710b8","scope":"openid profile email","sid":"31947692-5bce-411d-93c2-5e20770710b8"}'.