@schemavaults/example-nextjs-resource-server
An example Next.js app and API that signs its users in with a SchemaVaults auth server. Each demo integrates a different way. They are grouped by the client app they sign in as.
The demos below sign in as two different client apps registered on the auth server, and one app can't be both. Once a client secret is set on an app, the auth server requires that secret on every token request for the app. The public-client sign-ins have no secret to send, so they stop working for an app that has one.
Register two apps: keep the public client's app without a secret, and give the secret to the confidential client's app only.
This deployment uses the same app (example-nextjs-resource-server) for both, so the sign-ins of one kind or the other will fail.
Public client
No client secret: PKCE alone protects these sign-ins.
SCHEMAVAULTS_CLIENT_APP_ID: example-nextjs-resource-server
SDK sign-in
Sign in with the SchemaVaults SDKs. This app's session routes keep the refresh token in an HttpOnly cookie on its own domain, and the account page calls the protected API with an access token.
openid-client
Standard OpenID Connect with the off-the-shelf openid-client package and no SchemaVaults SDK: the authorization code flow with PKCE.
Confidential client
Authenticates with its client secret, which stays on this server.
OPENID_CLIENT_DEMO_CONFIDENTIAL_CLIENT_ID: example-nextjs-resource-server
openid-client, confidential
The same openid-client flow as a confidential client: the token request also presents the app's client secret (client_secret_basic) on top of PKCE.
API
This app's own API, protected by the auth server's access tokens.
API reference
Generated from the API's @schemavaults/openapi-operations declarations, with the permissions each operation requires.