# OIDC Bridge

## Summary

When the OIDC bridge is enabled, Pomerium acts as an OpenID Connect (OIDC) provider for upstream applications. An upstream application that supports OIDC sign-in can use Pomerium as its identity provider, and users sign in with their existing Pomerium session.

The OIDC bridge can be configured globally, as the default for all routes, or on individual routes. Route-level settings replace the global settings entirely: they are not merged.

The OIDC bridge requires a configured identity provider (`idp_provider`). It is not supported with the hosted authenticate service.

### Endpoints

The issuer is your [authenticate service URL](https://www.pomerium.com/docs/reference/service-urls.md#authenticate-service-url). Applications can discover the remaining endpoints from `/.well-known/openid-configuration` on that URL:

| Endpoint      | Path                                |
| :------------ | :---------------------------------- |
| Discovery     | `/.well-known/openid-configuration` |
| Authorization | `/oidc/auth`                        |
| Token         | `/oidc/token`                       |
| UserInfo      | `/oidc/userinfo`                    |
| JWKS          | `/oidc/jwks.json`                   |

### Client ID

There is no client registration. An upstream application uses an `https` URL served by the route as its `client_id`, for example `https://app.example.com/`. The URL must not contain a query string, a fragment, credentials, or relative path components.

## Settings

| Setting | Type | Description |
| :-- | :-- | :-- |
| `enabled` | boolean | Whether the OIDC bridge is enabled. If the OIDC bridge settings are present and `enabled` is not set, the OIDC bridge is enabled. |
| [`client_secret`](#client-secret) | string | Optional client secret. |
| [`redirect_uris`](#redirect-uris) | array of strings | Optional list of allowed redirect URIs. |

### Client secret

By default, upstream applications are treated as public clients and must use [PKCE](https://datatracker.ietf.org/doc/html/rfc7636). Set a client secret for upstream applications that do not support public clients or PKCE. Applications then authenticate to the token endpoint with the `client_id` and this secret.

### Redirect URIs

A list of redirect URIs that upstream applications may use when signing in through the OIDC bridge. A `redirect_uri` must exactly match an entry in the list.

When the list is empty, any `redirect_uri` on the same host as the `client_id` is allowed, as long as its path is the `client_id` path or a subpath of it.

## How to configure

**Core:**

| **Config file keys** | **Type** | **Usage**    |
| :------------------- | :------- | :----------- |
| `oidc_bridge`        | `object` | **optional** |

`oidc_bridge` can be set at the top level of the configuration file, as the default for all routes, or on an individual route.

### Examples

```yaml
oidc_bridge:
  enabled: true

routes:
  - from: https://app.example.com
    to: http://app.internal:8080
    oidc_bridge:
      enabled: true
      client_secret: REPLACE_ME
      redirect_uris:
        - https://app.example.com/oauth/callback
```

**Enterprise:**

Set the default **OIDC Bridge** settings in the Console's global settings. To override them for a single route, use the **OIDC Bridge** tab when you edit the route.

**Kubernetes:**

| **[Parameter name](https://www.pomerium.com/docs/deploy/k8s/reference.md#oidcbridge)** | **Type** | **Usage** |
| :-- | :-- | :-- |
| `oidcBridge` | object | **optional** |

The global `oidcBridge` settings take these fields:

- `enabled`
- `redirectUris`
- `secretRef`: a `namespace/name` reference to a Secret with a `client_secret` key

### Examples

```yaml
apiVersion: ingress.pomerium.io/v1
kind: Pomerium
metadata:
  name: global
spec:
  oidcBridge:
    enabled: true
```

To override the global settings for a single route, use Ingress annotations. `oidc_bridge_secret` names a Secret with a `client_secret` key:

```yaml
ingress.pomerium.io/oidc_bridge: 'true'
ingress.pomerium.io/oidc_bridge_redirect_uris: '["https://app.example.com/oauth/callback"]'
ingress.pomerium.io/oidc_bridge_secret: app-oidc-bridge
```
