I am covering the SAFE Stack as a part of my F# webdev series. In the latest installment I am trying to do a login page using Azure AD, but I am running into difficulties with the challenge request.
It is no problem to redirect the user to the Azure AD login using ChallengeAsync, but doing that through the Vite proxy server results in an incorrect redirect uri being passed in the url. Here is my setup on the server side.
let main args =
let builder = WebApplication.CreateBuilder(args)
builder.Services.AddGiraffe() |> ignore
builder.Services
.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
|> ignore
let app = builder.Build()
app
.UseAuthentication()
.Use(Func<HttpContext,RequestDelegate,Task>(fun ctx next -> task {
if ctx.User = null || ctx.User.Identity.IsAuthenticated = false then
if app.Environment.IsDevelopment() then
return! ctx.ChallengeAsync(AuthenticationProperties(RedirectUri="http://localhost:8080"))
else
return! ctx.ChallengeAsync()
else
return! next.Invoke(ctx)
}))
.UseGiraffe(webApp)
app.Run()
0 // Exit code
I really wish that return! ctx.ChallengeAsync(AuthenticationProperties(RedirectUri="http://localhost:8080")) did what I wanted, but it has no effect, and instead the redirect uri has the server 5000 port instead. I am not sure what I should do here.
I am covering the SAFE Stack as a part of my F# webdev series. In the latest installment I am trying to do a login page using Azure AD, but I am running into difficulties with the challenge request.
It is no problem to redirect the user to the Azure AD login using ChallengeAsync, but doing that through the Vite proxy server results in an incorrect redirect uri being passed in the url. Here is my setup on the server side.
I really wish that
return! ctx.ChallengeAsync(AuthenticationProperties(RedirectUri="http://localhost:8080"))
did what I wanted, but it has no effect, and instead the redirect uri has the server 5000 port instead. I am not sure what I should do here.