Fork me on GitHub
#graphql
<
2019-09-19
>
erwinrooijakkers09:09:19

FYI @gklijs, this works:

(def roles-interceptor
  {:enter (fn [context]
    (assoc-in context [:request :lacinia-app-context :custom-role-key] :some-value})
And inject it :after inject-app-context:
(defn- inject-roles-interceptor
  [interceptors]
  (pedestal/inject interceptors
                   jwt/roles-interceptor
                   :after
                   ::pedestal/inject-app-context))

erwinrooijakkers09:09:38

Thanks to the help of @nenadalm

gklijs09:09:29

Thanks, not sure I get to it, but would like to have a more proper example on authenticating graphql for the GraphQL Summit talk.

erwinrooijakkers09:09:25

Ah we authenticate using Keycloak and Keycloak Gatekeeper

erwinrooijakkers09:09:33

Sidecar container in Kubernetes 🙂

erwinrooijakkers09:09:42

And then Keycloak provides the JWT

erwinrooijakkers09:09:05

So both the frontend and backend run this Keycloak Gatekeeper sidecar container

erwinrooijakkers09:09:12

And then it just works 🙂

erwinrooijakkers09:09:35

User is redirected to Keycloak login screen and when logged in the cookies are shared between frontend and backend

erwinrooijakkers09:09:54

So because the frontend session is valid (logged in user) the request reaches the backend

erwinrooijakkers09:09:00

With the right cookies

erwinrooijakkers09:09:37

And then you add a little roles-interceptor and the information regarding the roles is available in the resolvers

erwinrooijakkers09:09:00

Then you can determine there what data the user is allowed to query

gklijs09:09:09

Sounds easy enough, thanks

orestis13:09:56

We use plain old cookies for Authentication, an interceptor added before lacinia allows or rejects requests at the http level -- then we have the user available in the resolver to do fine-grained authorization.