Oauth2 Auth (Google Login)
ShipClojure Datom uses reitit and ring for handling API calls. All of the middleware and configuration is done through ring. Reitit is used only for the final routing part where needed.
I chose this architecture because ring & reitit have different approaches to middleware configuration, that builds confusion when trying to mix them together. You cannot have one without the other as ring is the underlying framework that transforms requests and responses to and from clojure maps, and reitit is just a router based on the content of the request map.
ShipClojure provides OAuth2 support for any login providers. By default, the Google provider is already setup.
Setting up Google login
Follow the steps here to create a google application and get your client-id & client-secret.
Important: Make sure the redirect URI set-up in your application matches the format
/oauth2/:provider/callbackwhich is the default for shipclojure
Add these properties to ~/resources/.secrets.edn under [:oauth2/connection-providers :connection.provider/google] {:client-id "123" :client-secret" "123"}
That's it! Your google login should be ready
Adding a new Oauth2 Provider
Add the new entry in system.edn under
:oauth2/providersAdd the client secrets (
:client-id&:client-secret) in yourresources/.{prod|dev}-secrets.ednfile{:oauth2/connection-providers {:connection.provider/google {:client-id "public client id" :client-secret "client secret"} :new-provider {:client-id "public client id" :client-secret "secret shhh!"}}}Test your connection by visiting
/oauth2/:providerand if everything was setup correctly, your new provider should work