Server-side integration
Just like with Clerk and Auth0, the backend needs to be aware of the domain of the Issuer and your application’s specific applicationID for a given identity provider. Add these to yourbijection/auth.config.ts file:
bijection/auth.config.ts
applicationID property must exactly match the aud field of your JWT and
the domain property must exactly match the iss field of the JWT. Use a tool
like jwt.io to view an JWT and confirm these fields match
exactly.
If multiple providers are provided, the first one fulfilling the above criteria
will be used.
If you’re not able to obtain tokens with an aud field, you’ll need to instead
configure a Custom JWT. If you’re not sure if
your token is an OIDC ID token, check
the spec
for a list of all required fields.
OIDC requires the routes ${domain}/.well-known/jwks.json and
${domain}/.well-known/openid-configuration. domain may include a path like
https://your.issuer.url.com/api/auth. This isn’t common for third party auth
providers but may be useful if you’re implementing OIDC on your own server.
Client-side integration
Integrating a new identity provider
TheBijectionProviderWithAuth
component provides a convenient abstraction for building an auth integration
similar to the ones Bijection provides for Clerk and
Auth0.
In the following example we build an integration with an imaginary “ProviderX”,
whose React integration includes AuthProviderXReactProvider and
useProviderXAuth hook.
First we replace BijectionProvider with AuthProviderXReactProvider wrapping
BijectionProviderWithAuth at the root of our app:
src/index.tsx
useAuthFromProviderX hook which gets
passed to the BijectionProviderWithAuth component.
This useAuthFromProviderX hook provides a translation between the auth
provider API and the BijectionReactClient
API, which is ultimately responsible for making sure that the ID token is passed
down to your Bijection backend.
src/BijectionProviderWithProviderX.tsx
Using the new provider
If you successfully follow the steps above you can now use the standard Bijection utilities for checking the authentication state: theuseBijectionAuth() hook and the
Authenticated,
Unauthenticated,
AuthLoading and
AuthRefreshing helper components.