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

Tokens generated via vault_jwt_auth_backend_role won't retain token_policies #567

Closed
nszilard opened this issue Oct 16, 2019 · 2 comments
Closed

Comments

@nszilard
Copy link

Terraform Version

Terraform v0.12.2
+ provider.aws v2.32.0
+ provider.local v1.4.0
+ provider.null v2.1.2
+ provider.template v2.1.2
+ provider.vault v2.4.0

Vault Version

$ vault --version
Vault v1.2.0

$ curl --silent https://**REDACTED**/v1/sys/health | jq  .version
"1.2.0"

Affected Resource(s)

  • vault_jwt_auth_backend_role

Terraform Configuration Files

resource "vault_jwt_auth_backend_role" "oidc_role" {
  count = var.google_oidc_auth_backend == null ? 0 : 1

  role_name  = vault_identity_entity.user.name
  backend    = var.google_oidc_auth_backend.path
  role_type  = var.google_oidc_auth_backend.type
  user_claim = "email"

  token_policies = var.policies.*.name

  oidc_scopes = [
    "openid",
    "email"
  ]
  bound_audiences = [
    var.google_oidc_auth_backend.oidc_client_id
  ]
  allowed_redirect_uris = [
    "http://localhost:8250/oidc/callback",
    "https://**REDACTED**/ui/vault/auth/oidc/oidc/callback",
  ]
}

Expected Behavior

Terraform applies successfully.
After a successful attempt to authenticate via the OIDC role, the generated token should inherit all the token_policies set in the role.

Actual Behavior

Terraform applies successfully.
However, tokens generated via the role only has the default policy.

Steps to Reproduce

Using Terraform

  1. terraform apply
  2. vault read auth/oidc/role/testRole
Key                        Value
---                        -----
allowed_redirect_uris      [https://**REDACTED**/ui/vault/auth/oidc/oidc/callback http://localhost:8250/oidc/callback]
bound_audiences            [**REDACTED**]
bound_claims               <nil>
bound_subject              n/a
claim_mappings             <nil>
clock_skew_leeway          0
expiration_leeway          0
groups_claim               n/a
not_before_leeway          0
oidc_scopes                [openid email]
role_type                  oidc
token_bound_cidrs          []
token_explicit_max_ttl     0s
token_max_ttl              0s
token_no_default_policy    false
token_num_uses             0
token_period               0s
token_policies             [testPolicy]
token_ttl                  0s
token_type                 default
user_claim                 email
verbose_oidc_logging       false
  1. vault login -method=oidc role=testRole
  2. Read token attributes:
Key                  Value
---                  -----
token                s.66vdoZMKPaF17lTGaYYy49M0
token_accessor       rDx7pyv6ow94YPG1F3dws9bC
token_duration       12h
token_renewable      true
token_policies       ["default"]
identity_policies    []
policies             ["default"]
token_meta_role      testRole

Compared to using Vault API

  1. vault auth enable oidc
vault write auth/oidc/config \
  oidc_discovery_url="https://accounts.google.com" \
  oidc_client_id="**REDACTED**" \
  oidc_client_secret="**REDACTED**"
vault write auth/oidc/role/testRole \
  ttl=12h \
  user_claim="email" \
  oidc_scopes="openid,email" \
  bound_audiences="**REDACTED**" \
  allowed_redirect_uris="http://localhost:8250/oidc/callback,https://**REDACTED**/ui/vault/auth/oidc/oidc/callback" \
  policies=testPolicy
  1. vault login -method=oidc role=testRole
  2. Read token attributes:
Key                  Value
---                  -----
token                s.4grSMTZIwuGgCp1hNWeKjzNp
token_accessor       zfC3aWj7j7k9NlcUOtmykOth
token_duration       12h
token_renewable      true
token_policies       ["testPolicy" default"]
identity_policies    []
policies             ["testPolicy" "default"]
token_meta_role      testRole
@lawliet89
Copy link
Contributor

Can you try upgrading to Vault 1.2.3?

Seems to be fixed by hashicorp/vault-plugin-auth-jwt#67 that was released with 1.2.3.

@nszilard
Copy link
Author

Thank you @lawliet89! I did upgrade to the latest version and it did fix the issue.

However, my question could still be of interest, as the server's version remained the same in the scenario described above yet the different methods of creating and OIDC role resulted in a different outcome.

Happy to close the ticket though if you don't think any further investigation is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants