graphql

erwinrooijakkers 2019-09-19T09:12:19.022800Z

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))

erwinrooijakkers 2019-09-19T09:12:38.023200Z

Thanks to the help of @nenadalm

gklijs 2019-09-19T09:15:29.024500Z

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

erwinrooijakkers 2019-09-19T09:25:25.025100Z

Ah we authenticate using Keycloak and Keycloak Gatekeeper

erwinrooijakkers 2019-09-19T09:25:33.025400Z

Sidecar container in Kubernetes 🙂

erwinrooijakkers 2019-09-19T09:25:42.025700Z

And then Keycloak provides the JWT

erwinrooijakkers 2019-09-19T09:28:25.027200Z

Like this

erwinrooijakkers 2019-09-19T09:29:05.027800Z

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

erwinrooijakkers 2019-09-19T09:29:12.028Z

And then it just works 🙂

erwinrooijakkers 2019-09-19T09:29:35.028600Z

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

erwinrooijakkers 2019-09-19T09:29:54.029Z

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

erwinrooijakkers 2019-09-19T09:30:00.029200Z

With the right cookies

erwinrooijakkers 2019-09-19T09:30:37.029600Z

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

erwinrooijakkers 2019-09-19T09:31:00.030100Z

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

gklijs 2019-09-19T09:36:09.030500Z

Sounds easy enough, thanks

erwinrooijakkers 2019-09-19T09:41:45.030800Z

🙂

orestis 2019-09-19T13:37:56.031800Z

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.