As of `v0.4.7`, `zrok` includes OAuth integration for both Google and GitHub for `zrok access public` public frontends.
This integration allows you to create public shares and request that the public frontend authenticate your users against either the Google or GitHub OAuth endpoints (using the user's Google or GitHub accounts). Additionally, you can restrict the email address domain associated with the count to a list of domains that you provide when you create the share.
This is a first step towards a more comprehensive portfolio of user authentication strategies in future `zrok` releases.
## Planning for the OAuth Frontend
The current implementation of the public frontend OAuth integration uses a separate listening address and port from the public frontend itself.
After this frontend is configured, we'll use the OAuth frontend address when creating the OAuth clients for Google and GitHub.
## Configuring a Google OAuth Client
### OAuth Content Screen
Configure the application in the OAuth Content Screen.
In your oauth provider of choice's setup you would be prompted to create a client for accessing their services. It will ask for a redirect url. The format is: `<scheme>://<redirect_url>:<port>/<provider>/oauth` and as an example: `http://zrok.io:28080/google/oauth` This is also where you will find the client_id and client_secret.
redirect_url is what we will tell the oauth providers to callback with the authorization result. This will be whatever domain you've chosen to host the access server against without the scheme or port. This will get combined with the above port.
We spin up a zitadel oidc server on the specified port that handled all of the oauth handshaking. With the response we create a cookie with the name `zrok-access`.
## Enabling Oath on Share
To utilize the oauth integration on the access point we need to add a few more flags to our share command. There are three new flags:
-`provider` : This is the provider to authenticate against. Options are the same as above dependant on what the acess point is configured for
-`oauth-domains` : A list of valid email domains that are allowed to access the service. for example `gmail.com`
-`oauth-check-interval` : How long a `zrok-access` token is valid for before reinitializing the oauth flow. This is defaultly 3 hours.
That's all it takes!
Now when a user connects to your share they will be prompted with the chosen oauth provider and allowed based on your allowed domains. Simply restarting the service won't force a reauth for users either. Changing the `provider` or `oauth-check-interval` will, however.