Skip to content

Add Kubernetes-friendly OCI authentication methods#1

Open
sanjaynagi wants to merge 2 commits into
incsteps:mainfrom
sanjaynagi:feature/k8s-auth
Open

Add Kubernetes-friendly OCI authentication methods#1
sanjaynagi wants to merge 2 commits into
incsteps:mainfrom
sanjaynagi:feature/k8s-auth

Conversation

@sanjaynagi

@sanjaynagi sanjaynagi commented Jun 18, 2026

Copy link
Copy Markdown

Motivation

The plugin previously supported only two authentication methods:

  • Simple (SimpleAuthenticationDetailsProvider) — inline tenantId/userId/fingerprint/privateKey
  • Config file (ConfigFileAuthenticationDetailsProvider) — ~/.oci/config

Both require placing long-lived API keys / private keys into the runtime, which is undesirable in Kubernetes where you don't want to ship credentials into pods. This PR adds OKE Workload Identity, the credential-less method OCI provides for pods running in an Oracle Kubernetes Engine (enhanced) cluster.

What's added

A new oci.authType config option (and OCI_AUTH_TYPE env var) selects the method:

authType Use case
workload_identity OKE Workload Identity — pod-level, recommended for Kubernetes
simple / config_file Existing behavior, unchanged
auto (default) Existing behavior: inline credentials when supplied, otherwise ~/.oci/config

The existing auto behavior is unchanged and backward-compatible: inline credentials if present, otherwise the local config file. Workload Identity is opt-in via authType = 'workload_identity'.

Changes

  • AuthentificationDetailProvider — adds the workload_identity method alongside the existing simple/config_file/auto paths, with a simple auth-type switch and clear errors for unknown/misconfigured types.
  • OciConfig — new authType and tokenPath config options with env-var fallback; getConfiguredRegion() accessor.
  • OciClient — derives the region from the provider (RegionProvider) when none is configured, so OKE deployments need no explicit region.
  • build.gradle — adds com.oracle.oci.sdk:oci-java-sdk-addons-oke-workload-identity:3.80.3.
  • Docs — new Authentication section with an OKE Workload Identity guide.
  • Tests — auth-type normalization/selection and config resolution.

The service account token is read from the OKE SDK's default pod mount path and is customisable via oci.tokenPath.

Example (OKE Workload Identity)

oci {
    authType = 'workload_identity'
    region   = 'us-ashburn-1'
}

🤖 Generated with Claude Code

The plugin previously only supported inline API key credentials
(SimpleAuthenticationDetailsProvider) and the local ~/.oci/config file,
neither of which is suitable for Kubernetes where shipping long-lived
API keys into pods is undesirable.

Add the credential-less providers OCI offers for Kubernetes/OKE:

- workload_identity: OKE Workload Identity (pod-level, recommended for K8s)
- instance_principal: Instance Principals (OKE worker nodes / OCI VMs)
- resource_principal: Resource Principals (Functions etc.)

Changes:
- New `oci.authType` config option (and OCI_AUTH_TYPE env) selecting the
  method, with an `auto` default that detects the environment and prefers
  credential-less methods (inline -> workload identity -> resource
  principal -> config file).
- New optional `oci.tokenPath` for the OKE service account token.
- OciClient now derives the region from the provider (RegionProvider)
  when none is explicitly configured, so K8s deployments need no region.
- Add oci-java-sdk-addons-oke-workload-identity dependency.
- Tests for auth-type normalization/selection and config resolution.
- Document the auth methods, with an OKE Workload Identity guide.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sanjaynagi-eit

Copy link
Copy Markdown

hey there @incsteps

Made this PR as we would like to use nf-oci on K8s but currently auth is a bit tricky. Please review if you can! thank you!

- Drop the reimplemented instance_principal/resource_principal methods and
  env auto-detection; keep the original auto behaviour (inline credentials,
  then ~/.oci/config) and add only the new workload_identity method.
- Make the service account token path customisable via oci.tokenPath, relying
  on the OKE SDK default instead of a hardcoded constant.
- Simplify normalizeAuthType to accept one canonical name per type.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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