Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to understand optionality of required claims. #2

Closed
fisx opened this issue Oct 6, 2022 · 1 comment
Closed

Trying to understand optionality of required claims. #2

fisx opened this issue Oct 6, 2022 · 1 comment

Comments

@fisx
Copy link

fisx commented Oct 6, 2022

Why AuthRequired (Maybe claims), and not AuthRequired claims? It seems like the former requires you to always add a dynamic check to the handler. The latter would allow to write claim types that can be completely ignore by the handler, because it already knows it's all there from the types.

I'll try to answer this myself, just started reading. :-)

@fisx
Copy link
Author

fisx commented Oct 10, 2022

and here is the answer: i was reading the README wrong. :) AuthRequired and AuthOptional both work as expected, see here:

[...]
    :<|> "login" :> AuthRequired (ClaimSub Text) :> Get '[JSON] Text
    :<|> "login-optional" :> AuthOptional (ClaimSub Text) :> Get '[JSON] Text
[...]
        :<|> runAppM . resourceHandler . Just
        :<|> runAppM . resourceHandler
[...]
resourceHandler :: Maybe (ClaimSub Text) -> AppM Text
resourceHandler = [...]
[...]

@fisx fisx closed this as completed Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant