Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more configuration options for JWT Auth Backend #1244

Merged
merged 3 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions vault/resource_jwt_auth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ func jwtAuthBackendResource() *schema.Resource {
Description: "Client Secret used for OIDC",
},

"oidc_response_mode": {
Type: schema.TypeString,
Optional: true,
Description: "The response mode to be used in the OAuth2 request. Allowed values are 'query' and 'form_post'. Defaults to 'query'. If using Vault namespaces, and oidc_response_mode is 'form_post', then 'namespace_in_state' should be set to false.",
},

"oidc_response_types": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "The response types to request. Allowed values are 'code' and 'id_token'. Defaults to 'code'. Note: 'id_token' may only be used if 'oidc_response_mode' is set to 'form_post'.",
},

"jwks_url": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -123,13 +136,15 @@ func jwtAuthBackendResource() *schema.Resource {
Computed: true,
Description: "The accessor of the JWT auth backend",
},

"local": {
Type: schema.TypeBool,
ForceNew: true,
Optional: true,
Default: false,
Description: "Specifies if the auth method is local only",
},

"provider_config": {
Type: schema.TypeMap,
Optional: true,
Expand All @@ -138,6 +153,14 @@ func jwtAuthBackendResource() *schema.Resource {
Type: schema.TypeString,
},
},

"namespace_in_state": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Pass namespace in the OIDC state parameter instead of as a separate query parameter. With this setting, the allowed redirect URL(s) in Vault and on the provider side should not contain a namespace query parameter. This means only one redirect URL entry needs to be maintained on the OIDC provider side for all vault namespaces that will be authenticating against it. Defaults to true for new configs.",
},

"tune": authMountTuneSchema(),
},
}
Expand Down Expand Up @@ -171,13 +194,16 @@ var (
"oidc_discovery_ca_pem",
"oidc_client_id",
"oidc_client_secret",
"oidc_response_mode",
"oidc_response_types",
"jwks_url",
"jwks_ca_pem",
"jwt_validation_pubkeys",
"bound_issuer",
"jwt_supported_algs",
"default_role",
"provider_config",
"namespace_in_state",
}
)

Expand Down
5 changes: 5 additions & 0 deletions vault/resource_jwt_auth_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func TestAccJWTAuthBackend_OIDC(t *testing.T) {
resource.TestCheckResourceAttr("vault_jwt_auth_backend.oidc", "bound_issuer", "api://default"),
resource.TestCheckResourceAttr("vault_jwt_auth_backend.oidc", "oidc_client_id", "client"),
resource.TestCheckResourceAttr("vault_jwt_auth_backend.oidc", "oidc_client_secret", "secret"),
resource.TestCheckResourceAttr("vault_jwt_auth_backend.oidc", "oidc_response_mode", "query"),
resource.TestCheckResourceAttr("vault_jwt_auth_backend.oidc", "oidc_response_types.#", "1"),
resource.TestCheckResourceAttr("vault_jwt_auth_backend.oidc", "oidc_response_types.0", "code"),
resource.TestCheckResourceAttr("vault_jwt_auth_backend.oidc", "type", "oidc"),
resource.TestCheckResourceAttr("vault_jwt_auth_backend.oidc", "default_role", "api"),
),
Expand Down Expand Up @@ -201,6 +204,8 @@ resource "vault_jwt_auth_backend" "oidc" {
path = "%s"
type = "oidc"
default_role = "api"
oidc_response_mode = "query"
oidc_response_types = ["code"]
}
`, path)
}
Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/jwt_auth_backend.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ The following arguments are supported:

* `oidc_client_secret` - (Optional) Client Secret used for OIDC backends

* `oidc_response_mode` - (Optional) The response mode to be used in the OAuth2 request. Allowed values are `query` and `form_post`. Defaults to `query`. If using Vault namespaces, and `oidc_response_mode` is `form_post`, then `namespace_in_state` should be set to `false`.

* `oidc_response_types` - (Optional) List of response types to request. Allowed values are 'code' and 'id_token'. Defaults to `["code"]`. Note: `id_token` may only be used if `oidc_response_mode` is set to `form_post`.

* `jwks_url` - (Optional) JWKS URL to use to authenticate signatures. Cannot be used with "oidc_discovery_url" or "jwt_validation_pubkeys".

* `jwks_ca_pem` - (Optional) The CA certificate or chain of certificates, in PEM format, to use to validate connections to the JWKS URL. If not set, system certificates are used.
Expand All @@ -93,6 +97,8 @@ The following arguments are supported:

* `local` - (Optional) Specifies if the auth method is local only.

* `namespace_in_state` - (Optional) Pass namespace in the OIDC state parameter instead of as a separate query parameter. With this setting, the allowed redirect URL(s) in Vault and on the provider side should not contain a namespace query parameter. This means only one redirect URL entry needs to be maintained on the OIDC provider side for all vault namespaces that will be authenticating against it. Defaults to true for new configs

* tune - (Optional) Extra configuration block. Structure is documented below.

The `tune` block is used to tune the auth backend:
Expand Down