The OAuth2Plugin schema defines the configuration for OAuth2 authentication in Rusty Beam. This plugin enables users to authenticate using OAuth2 providers (Google, GitHub, Azure AD, etc.) and sets the authenticated_user
metadata for other plugins to use.
clientIdEnv
, clientSecretEnv
, and redirectUriEnv
configuration properties.
Schema URL: https://rustybeam.net/schema/OAuth2Plugin
Parent Schema: https://rustybeam.net/schema/AuthPlugin
Property | Type | Cardinality | Description |
---|---|---|---|
redirectUriEnv | https://rustybeam.net/schema/Text | 1 | Environment variable name to read redirect URI from. Required. |
name | https://rustybeam.net/schema/Text | 0..1 | Plugin instance name for identification. Defaults to "google-oauth2" if not specified. |
clientIdEnv | https://rustybeam.net/schema/Text | 1 | Environment variable name to read client ID from. Required. |
clientSecretEnv | https://rustybeam.net/schema/Text | 1 | Environment variable name to read client secret from. Required. |
loginPath | https://rustybeam.net/schema/Text | 0..1 | The path where login requests will be handled. Defaults to "/auth/{name}/login" where {name} is the plugin instance name. |
provider | https://rustybeam.net/schema/Text | 0..1 | The OAuth2 provider to use (google, github). Defaults to "google" unless the plugin name contains "github". |
<!-- Google OAuth2 configuration -->
<td itemprop="plugin" itemscope itemtype="https://rustybeam.net/schema/OAuth2Plugin">
<span itemprop="library">file://./plugins/librusty_beam_oauth2.so</span>
<span itemprop="clientIdEnv">GOOGLE_CLIENT_ID</span>
<span itemprop="clientSecretEnv">GOOGLE_CLIENT_SECRET</span>
<span itemprop="redirectUriEnv">GOOGLE_OAUTH2_CALLBACK</span>
</td>
<!-- GitHub OAuth2 configuration with explicit provider -->
<td itemprop="plugin" itemscope itemtype="https://rustybeam.net/schema/OAuth2Plugin">
<span itemprop="library">file://./plugins/librusty_beam_oauth2.so</span>
<span itemprop="name">github-oauth2</span>
<span itemprop="clientIdEnv">GITHUB_CLIENT_ID</span>
<span itemprop="clientSecretEnv">GITHUB_CLIENT_SECRET</span>
<span itemprop="redirectUriEnv">GITHUB_REDIRECT_URI</span>
<span itemprop="loginPath">/auth/github/signin</span>
<span itemprop="provider">github</span>
</td>
The plugin reads OAuth2 credentials from environment variables. The variable names must be specified in the configuration:
Variable | Required | Description | Example |
---|---|---|---|
Variable specified by clientIdEnv |
Yes | OAuth2 client ID | 123456789.apps.googleusercontent.com |
Variable specified by clientSecretEnv |
Yes | OAuth2 client secret | GOCSPX-xxxxxxxxxxxxxxxxxxxx |
Variable specified by redirectUriEnv |
Yes | OAuth2 redirect/callback URL | http://localhost:3000/auth/google/callback |
This plugin automatically provides these endpoints:
{loginPath}
- Initiates OAuth2 flow (defaults to /auth/{name}/login
){callback path from redirect URI}
- Handles OAuth2 callback (derived from the redirect URI)/auth/logout
- Clears authentication session/auth/user
- Returns current user information as HTML with schema.org/Person microdataloginPath
property. The callback path is automatically derived from the redirect URI specified in the environment variable.
Users authenticated via OAuth2 are automatically granted the 'user' role. Administrators can be designated by adding their email to the administrators role in the authorization plugin configuration.
The plugin sets the following metadata for other plugins to use:
authenticated_user
- User's email addressuser_name
- User's display name.env
file for local development (excluded from version control)