Closed nodew closed 4 years ago
There's no reason why it can't, Saturn is just a wrapper over ASP .NET. However, it could be nice to have a sample application showing a basic identity server example. Most of the time you can use the service_config
command inside application
to add custom middleware etc.
Hello everybody, can please someone provide sample solution with identity server integration? :) THX
If this is still relevant, here's the solution:
Add IdentityServer4.AccessTokenValidation NuGet to your entry point project.
Write a function that adds identity server authentication capabilities to your application builder:
let identityServer (services:IServiceCollection) = let auth (options:IdentityServerAuthenticationOptions) = options.Authority <- "yourIdentyServerURL" options.ApiName <- "yourApiName" options.ApiSecret <- "yourApiSecret" () let authBuilder = services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) authBuilder.AddIdentityServerAuthentication(auth) |> ignore services.AddAuthorization()
Write a function that adds the authentication feature to the application builder:
let authentication (app:IApplicationBuilder) = app.UseAuthentication()
Add a pipe_through operation into any router where you wish to authorize the role of the request sender:
let appRouter = router { pipe_through (Auth.requireRole JWT "yourRoleName") }
And finally, configure your application computation expression like this:
let app = application { service_config identityServer app_config authentication use_router appRouter }
@yurotor thanks for this guide. ❤️
Can saturn work with identityserver? If can, is there some demos?