Closed Dzoukr closed 3 years ago
Please feel free to reword, cleanup, whatever fits your needs!
Instead of reviewing here I will merge first, make some changes and ask you to review the changes later if it still looks good 😘
Hi @Dzoukr, thanks a lot for the tutorial!
I've been following the instructions on building an app that uses JWT for authentication. Works smoothly in local development; however in production (or locally run dotnet run publish
and then navigate to .\publish\app to do dotnet Server.dll
), the app only shows the unauthenticated error message "User not logged in". Couldn't figure out what went wrong... would it be possible to get some hints from you on how to fix this?
// Server/WebApp.fs
let private mustBeLoggedIn : HttpHandler =
requiresAuthentication (RequestErrors.UNAUTHORIZED JwtBearerDefaults.AuthenticationScheme "" "User not logged in")
let webApp (cfg:Jwt.JwtConfiguration): HttpHandler =
choose [
Anonymous.anonymousAPI cfg
mustBeLoggedIn >=> choose [
Secured.securedAPI
]
htmlFile "public/index.html"
]
Link to full codebase here: https://github.com/chengh42/safe-auth-jwt
I hope this helps, my friend.