Skip to content

How to validate Kratos Session Cookie in ASP.NET Core WebApi #1072

Discussion options

You must be logged in to vote

So I now solved it for myself differently by creating a custom Authentication Handler, which takes care of checking the Cookie that gets send to the Web API.

Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    // ...
    services.AddSingleton(new KratosService("http://localhost:4433"));   
    services
        .AddAuthentication("Kratos")
        .AddScheme<KratosAuthenticationOptions, KratosAuthenticationHandler>("Kratos", null);
    // ...
}

If you are interested in the implementation that did the job for me, I have attached the additional files below. It is also worth mentioning, that Kratos supports two way of Authenticating: Cookies and Bearer Tokens, dependi…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@robinmanuelthiel
Comment options

@Benehiko
Comment options

@Benehiko
Comment options

@robinmanuelthiel
Comment options

Comment options

You must be logged in to vote
1 reply
@aeneasr
Comment options

Answer selected by robinmanuelthiel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants