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

Re-implement cookie auth #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Re-implement cookie auth #248

wants to merge 1 commit into from

Conversation

grav
Copy link
Contributor

@grav grav commented Nov 16, 2018

The docs say to create a resource with something like

{:access-control
            {:scheme        :cookie
             :cookie        "my-cookie-name"
             :verify (fn [cookie])}}

but that fails schema validation. Also, cookie validation is currently commented out.

This method re-implements cookie auth by looking for the cookie name in the "default" realm under :authorization -> :cookie.

Usage example:

{:access-control
                          {:scheme :cookie
                           :verify (fn [cookie]
                                     {:roles (when (= cookie "karen_wolf")
                                               #{:user})})
                           :authorization {:methods {:get :user}
                                           :cookie "brand"}}
                          :methods {:get {:produces #{"text/plain"}
                                          :response (fn [_ctx]
                                                      "I love cookies!")}}}

It does not support other realms apart from default, and it uses destructuring maybe a bit excessively ;-)

Re-implement cookie auth by looking for the cookie name in the "default" realm under the `:cookie` key
@boxxxie
Copy link
Contributor

boxxxie commented Sep 9, 2019

is this part of yada now? (i was able to use cookies with verify without issue)

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

Successfully merging this pull request may close these issues.

2 participants