
# All properties

Every property `spring_boot_starter_oauth2_client` reads. Registrations are `spring.security.oauth2.client.registration.<id>.*`, providers `spring.security.oauth2.client.provider.<id>.*`, and two keys switch tokens on for Feign clients. The starter's metadata (`lib/spring_gen/spring_metadata.json`) lists the same 26 keys.

## Why

Clients and providers differ by environment: a test realm in development, the production issuer later, secrets from the environment. They are properties, as in Spring Boot, so one build runs everywhere and a Spring Boot configuration can be copied over.

## Example

```yaml
# lib/resources/application.yml
spring:
  security:
    oauth2:
      client:
        registration:
          keycloak:
            client-id: neon-web
            client-secret: ${KEYCLOAK_SECRET}
            scope: [openid, profile, email]
            client-name: Neon login
          partner:
            client-id: shop
            client-secret: ${PARTNER_SECRET}
            authorization-grant-type: client_credentials
            client-authentication-method: client_secret_post
            scope: orders.read
          apple:
            client-id: books.neon.web
            client-authentication-method: client_secret_post
            client-secret-jwt:
              issuer: ABCDE12345
              key-id: XYZ987KEY1
              private-key-location: file:/run/secrets/AuthKey_XYZ987KEY1.p8
              lifetime: 1h
        provider:
          keycloak:
            issuer-uri: https://login.example.com/realms/neon
          partner:
            token-uri: https://id.partner.example/oauth2/token
  feign:
    oauth2:
      enabled: true
      client-registration-id: partner
```

The same in `.properties`:

```properties
# lib/resources/application.properties
spring.security.oauth2.client.registration.keycloak.client-id=neon-web
spring.security.oauth2.client.registration.keycloak.client-secret=${KEYCLOAK_SECRET}
spring.security.oauth2.client.registration.keycloak.scope=openid,profile,email
spring.security.oauth2.client.registration.keycloak.client-name=Neon login
spring.security.oauth2.client.registration.partner.client-id=shop
spring.security.oauth2.client.registration.partner.client-secret=${PARTNER_SECRET}
spring.security.oauth2.client.registration.partner.authorization-grant-type=client_credentials
spring.security.oauth2.client.registration.partner.client-authentication-method=client_secret_post
spring.security.oauth2.client.registration.partner.scope=orders.read
spring.security.oauth2.client.registration.apple.client-id=books.neon.web
spring.security.oauth2.client.registration.apple.client-authentication-method=client_secret_post
spring.security.oauth2.client.registration.apple.client-secret-jwt.issuer=ABCDE12345
spring.security.oauth2.client.registration.apple.client-secret-jwt.key-id=XYZ987KEY1
spring.security.oauth2.client.registration.apple.client-secret-jwt.private-key-location=file:/run/secrets/AuthKey_XYZ987KEY1.p8
spring.security.oauth2.client.registration.apple.client-secret-jwt.lifetime=1h
spring.security.oauth2.client.provider.keycloak.issuer-uri=https://login.example.com/realms/neon
spring.security.oauth2.client.provider.partner.token-uri=https://id.partner.example/oauth2/token
spring.feign.oauth2.enabled=true
spring.feign.oauth2.client-registration-id=partner
```

Secrets (`client-secret`, `client-secret-jwt.private-key`) belong in environment variables or a secret store, never in a committed file. None of them is ever logged.

## Registrations

Each key is `spring.security.oauth2.client.registration.<id>.<key>`. The registration's id (`keycloak`, `google`) is also the provider id unless `provider` says otherwise.

| Key | Type | Default | Meaning |
|---|---|---|---|
| `client-id` | `String` | required | The client's id at the provider. |
| `client-secret` | `String` | none | The client's secret; none for an app (a public client). A credential: never log it. |
| `client-authentication-method` | `client_secret_basic`, `client_secret_post`, `none` | `none` without a secret for `authorization_code`, else `client_secret_basic` | How the client proves who it is at the token endpoint. |
| `authorization-grant-type` | `authorization_code`, `client_credentials` | `authorization_code` with an `issuer-uri` or a known provider; required otherwise | A user's login, or the client's own tokens (server to server). |
| `redirect-uri` | `String` | `{baseUrl}/login/oauth2/code/{registrationId}` | Where the provider sends the browser back: a template, or an app's URI such as `neonbooks:/oauth2/callback`. The provider must accept it. |
| `scope` | `Set<String>` | none; the provider's defaults for the known providers | The scopes asked for, a comma list or a YAML list; `openid` makes it an OpenID Connect login (an ID token, checked). |
| `client-name` | `String` | the issuer, or the known provider's name | The name on the login page. |
| `provider` | `String` | the registration's id | The provider of the `provider.*` keys, or a known one: `google`, `github`, `facebook`, `okta`, `apple`. |
| `dpop` | `auto`, `true`, `false` | `auto` | DPoP (RFC 9449): the tokens are bound to the client's `DPoPKey` and every request carries a proof. `auto` binds them when the provider announces DPoP and the key outlives the program. Not in Spring Boot. |
| `response-mode` | `query`, `form_post` | `query`; `form_post` for the `apple` provider | How the provider returns the authorization response: in the redirect URI, or posted as a form to it (only a server's `oauth2Login()` receives it, over HTTPS only). Not in Spring Boot. |
| `native-sign-in` | `none`, `apple` | `apple` for the apple provider, else `none` | Apps (`spring_boot_starter_flutter_security`): `apple` signs in with Sign in with Apple's sheet on iOS and macOS instead of the browser; the code then goes to the registration's `token-uri`, the app's server. Not in Spring Boot. |

### client-secret-jwt: a client secret that is a JWT

Not in Spring Boot. Each key is `spring.security.oauth2.client.registration.<id>.client-secret-jwt.<key>`.

| Key | Type | Default | Meaning |
|---|---|---|---|
| `issuer` | `String` | required | The JWT's `iss` (Apple: the team id). |
| `key-id` | `String` | required | The JWT's `kid` (Apple: the key id). |
| `private-key-location` | `String` | none | The PKCS #8 private key (Apple's `.p8`), such as `file:/run/secrets/apple.p8` or `resources:...`; read at the first token request, never logged. Either this or `private-key` is required. |
| `private-key` | `String` | none | The PKCS #8 PEM itself instead of a location (from an environment variable; `\n` escapes allowed). A credential: never log it. |
| `audience` | `String` | the provider's issuer-uri | The JWT's `aud`. |
| `lifetime` | `Duration` | `1h` | How long each JWT is valid, at least `1m` and at most `180d`; made again when a tenth is left. |

## Providers

Each key is `spring.security.oauth2.client.provider.<id>.<key>`. A known provider (`google`, `github`, `facebook`, `okta`, `apple`) needs none of them, except Okta's `issuer-uri`.

| Key | Type | Default | Meaning |
|---|---|---|---|
| `issuer-uri` | `String` | none | The provider; the other endpoints come from its OpenID (or OAuth 2.0) metadata, whose `issuer` must equal it. Discovered at the first use, not at startup. |
| `authorization-uri` | `String` | from the metadata | The provider's login page. |
| `token-uri` | `String` | from the metadata | The token endpoint. |
| `user-info-uri` | `String` | from the metadata | The user-info endpoint. |
| `jwk-set-uri` | `String` | from the metadata | The provider's public keys; a server checks ID token signatures with them. |
| `user-info-authentication-method` | `header`, `form`, `query` | `header` | How the access token is sent to the user-info endpoint. |
| `user-name-attribute` | `String` | `sub` with `issuer-uri` | The attribute that names the user (`sub`, `login`, `email`). |

## Feign clients

| Key | Type | Default | Meaning |
|---|---|---|---|
| `spring.feign.oauth2.enabled` | `bool` | `false` | Whether Feign clients send the access token of an OAuth2 client registration. |
| `spring.feign.oauth2.client-registration-id` | `String` | none | The registration whose token Feign clients send; without it the Feign client's name is the registration id. |

## Writing values

- **Lists** (`scope`): comma separated, or a YAML list.
- **Durations** (`lifetime`): `1h`, `30m`, `PT1H` or milliseconds.
- **Templates** (`redirect-uri`): `{baseUrl}`, `{registrationId}`, `{action}`, `{baseScheme}`, `{baseHost}`, `{basePort}`, `{basePath}` as in Spring.
- **Renamed keys:** `spring.cloud.openfeign.oauth2.*` stops the start and names `spring.feign.oauth2.*`.

## In Spring (Java)

The `registration.*` and `provider.*` keys are Spring Boot's, with the same meanings. `dpop`, `response-mode`, `native-sign-in` and `client-secret-jwt.*` are additions. The Feign keys are Spring Cloud OpenFeign's without `cloud.openfeign`.

## See also

- [Registrations](registrations.md)
- [Tokens on Feign calls](feign.md)
- [DPoP](dpop.md)
