Skip to content

feat: add auth accessor resolution to IdentityTokenRole template field#305

Open
dyna-stadt wants to merge 1 commit intoredhat-cop:mainfrom
dyna-stadt:feat/add_accessor_identity_template
Open

feat: add auth accessor resolution to IdentityTokenRole template field#305
dyna-stadt wants to merge 1 commit intoredhat-cop:mainfrom
dyna-stadt:feat/add_accessor_identity_template

Conversation

@dyna-stadt
Copy link
Copy Markdown
Contributor

Summary

  • Extracts the ${auth/<path>/@accessor} placeholder resolution logic from Policy into a shared ResolveAuthAccessors utility function in api/v1alpha1/utils/commons.go
  • Refactors Policy.PrepareInternalValues() to use the new shared utility, removing duplicated code and unused imports
  • Adds auth accessor resolution to IdentityTokenRole.PrepareInternalValues(), enabling ${auth/<path>/@accessor} placeholders in the template field
  • Updates docs/identities.md with documentation and an example for the new IdentityTokenRole template accessor syntax

Motivation

The ${auth/<auth engine path>/@accessor} placeholder syntax was previously only supported in Policy HCL rules. However, identity token role templates often need to reference auth engine accessors as well (e.g. {{identity.entity.aliases.<accessor>.metadata.service_account_namespace}}). Without this feature, users had
to manually look up and hard-code accessor values, which change across Vault instances and are not portable.

Example

apiVersion: redhatcop.redhat.io/v1alpha1
kind: IdentityTokenRole
metadata:
  name: my-role
spec:
  authentication:
    path: kubernetes
    role: policy-admin
  key: my-key
  template: |
    {
      "namespace": {{identity.entity.aliases.${auth/kubernetes/@accessor}.metadata.service_account_namespace}}
    }

The operator resolves ${auth/kubernetes/@accessor} to the actual accessor value (e.g. auth_kubernetes_804f1655) before writing the role to Vault.

Note: The Vault role used for authentication must have read and list access to sys/auth for resolution to work. Unresolved placeholders are left as-is.

Extracts the auth accessor resolution logic from Policy into a shared ResolveAuthAccessors utility function and applies it to IdentityTokenRole's template field. This allows the same ${auth/<path>/@Accessor} placeholder syntax to be used in identity token role templates, automatically replacing placeholders with actual accessor values from Vault's sys/auth endpoint, ref: NOISSUE
@dyna-stadt
Copy link
Copy Markdown
Contributor Author

@raffaelespazzoli
Can you please review this one? Thanks!

@raffaelespazzoli
Copy link
Copy Markdown
Collaborator

please rebase off of main, you are using an old pipeline.

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

Successfully merging this pull request may close these issues.

2 participants