Authentication
Sign in with Google or GitHub
Both are off for a new project. Switch one on under Authentication → Sign-in methods, and list the addresses people may be sent back to under URL configuration.
The flow
your app ──▶ api.rezincore.com/v1/auth/authorize/google ──▶ Google
│
your app ◀── ?code=<one-time code> ◀── api.rezincore.com ◀────┘
│
└─▶ POST /v1/auth/exchange ──▶ a session token
1. Send the person's browser to Rezin Core
https://api.rezincore.com/v1/auth/authorize/google?project=<project ID>&redirect_to=https://app.example.com/signed-in
Use github in place of google for GitHub. redirect_to must be on the project's list; without it the Site URL is used. An address that is not listed is refused before the person is sent anywhere.
2. They come back to your address
With ?code=<one-time code> on success, or ?error=<reason>:
error | Meaning |
|---|---|
cancelled | The person backed out, or the provider reported an error |
not_verified | The provider did not vouch for a verified email address |
no_account | Nobody in this project has that identity or email, and self sign-up is off |
disabled | The account is disabled |
not_configured | The provider is not set up |
3. Swap the code for a session
From your page or your server, with your project key, within two minutes:
curl -s https://api.rezincore.com/v1/auth/exchange \
-H "apikey: $KEY" -H "content-type: application/json" -d '{"code":"<one-time code>"}'
The answer has the same shape as POST /v1/auth/signin. The code works once and only with a key of the same project.
If the account uses an authenticator app the answer is 401 code_required: send the same request again with "secondStepCode": "123456" added. See Authenticator app.
| Status | Code | When |
|---|---|---|
| 401 | bad_code | The one-time code has expired or was already used |
| 401 | code_required | The account uses an authenticator app |
| 401 | bad_second_step | The authenticator code is not right |
Which account a person gets
- The account already linked to that provider identity, if there is one.
- Otherwise the account in this project whose email equals the address the provider says is verified. It is linked from then on.
- Otherwise a new account, only if the project allows self sign-up. It joins the organization the project names and has no password.
A disabled account is refused before anything is linked to it.
Whose provider app is used
Rezin Core has its own app with each provider. A project that switches a provider on uses it unless the project supplies its own. With Rezin Core's app, the provider's consent screen names Rezin Core, not your application.
To use your own app:
- Create an OAuth app with the provider and register this callback address exactly:
| Provider | Callback address |
|---|---|
https://api.rezincore.com/v1/auth/callback/google | |
| GitHub | https://api.rezincore.com/v1/auth/callback/github |
- Put its client ID in the project's Sign-in methods.
- Put its client secret in the project's Secrets under exactly this name:
GOOGLE_CLIENT_SECRETorGITHUB_CLIENT_SECRET.
What is kept
Exactly two things from the provider: its own ID for the person, and an email address it says is verified (for GitHub, one marked primary and verified). The provider's token is used once in memory and never stored. Rezin Core does not read the person's repositories, mail, files or contacts.
The state value handed to the provider is random, single-use, valid ten minutes and kept only as a hash, and the request uses PKCE.
Limits
Starting a provider sign-in and exchanging a code count toward the project's sign-in attempts per network address. See Authentication settings.
More providers are being built. See More sign-in methods.