Comment on page
OpenID Connect is an identity layer built on top of OAuth2 it allows third-party applications to get basic information about your profile and verify your identity. Its purpose is to give you one login for multiple sites. You're probably familiar with it if you used Login with Google. For example, if you click Login with Google you'll be redirected to the Google page with verify form that you allow some website to get information from your profile for example email, name, etc.
As an identity provider one of our core features is Login with Defguard which allows you to log into other websites using your Defguard account so you don't have to care about multiple passwords and leaks. At this point you may have concern and ask is it safe? Yes, it's completely safe cause all information third party app will receive is the information that you allowed on redirect page. These information then are sent to third party app as IDToken which is basically JSON Web Token with additional claims like first name or email. Your password isn't send in any step of this.
To enable login with other app first you need to add it as new OpenID client. To do it navigate to OpenID Apps on the left side navigation then click Add new button.
OpenID add client form
Here are explained inputs
Name Name of your client Redirect URI URL on which user will be redirected with generated PKCE code example("https://myapp.com/redirect_uri") Scopes Scopes which your client will be using
After creating your client you can click on it on list and be redirected to detailed client page with it unique Client ID and Client secret codes.
Client ID is a public identifier for apps. Something like unique login so we can verify app URL matches it's Client ID. Client Secret Only known for authorization server(Defguard) and the applications as we using
Setup on authorization app if you want to login with Defguard.
OpenID Connect defines a discovery mechanism, called OpenID Connect Discovery, where an OpenID server publishes its metadata at a well-known URL, typically. This URL returns a JSON listing of the OpenID/OAuth endpoints, supported scopes and claims, public keys used to sign the tokens, and other details. The clients can use this information to construct a request to the OpenID server. Note For this endpoint to work correctly you have to set env variable named
DEFGUARD_URLwith URL of your defguard instance.
Set up your login with Defguard button to redirect to authorization endpoint which is
Below is sample authentication request which your app should do on Login with Defguard button
client_id=<YOUR_CLIENT_ID> // Generated by defguard available on app detail page
&redirect_uri=<YOUR_REDIRECT_URI> //Url on which user with code will be redirected
&scope=openid%20profile%20phone%20email // available scopes
&response_type=code // Currently only supported response is code
&state=<YOUR_STATE> // State to returned on redirect uri to verify request comes with Defguard
- 1.Client id and secret is generated by Defguard after creating your app you can see it on app detail page
- 2.Scope must contain OpenID
- 3.Available scopes are profile(all available info from user profile) phone and email
- 4.Currently only supported response_type is code.
- 5.Redirect URI is URL on which user will be redirected with generated PKCE code (Redirect URI must match URI declared on client creation otherwise error will be returned)
Successful authentication response
HTTP/1.1 302 Found
After receiving code from previous step you need to exchange it for token on token endpoint
Request Header and URL:
Request body: Need to be form encoded
- 1.Currently only supported grant_type is authorization_code
- 2.Code is your PKCE code received in previous step
Successful Token Response
HTTP/1.1 200 OK
- 1.As we using HS256 algorithm ID Token is signed using your app Client Secret
Every user that used Login with Defguard option can see in his profile name of every authorized app. If you revoke app then you will have to click allow on form with permissions again.
On the sidebar or by clicking links below you can find tutorials how to configure OpenID for: