oidc

package
v0.0.0-dev Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package oidc provides utilities for working with OIDC ID tokens.

This package is experimental and subject to change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatabricksOIDCTokenProvider

func NewDatabricksOIDCTokenProvider(cfg DatabricksOIDCTokenProviderConfig) auth.TokenProvider

NewDatabricksOIDCTokenProvider returns a new Databricks OIDC TokenProvider.

Types

type DatabricksOIDCTokenProviderConfig

type DatabricksOIDCTokenProviderConfig struct {
	// ClientID of the Databricks OIDC application. It corresponds to the
	// Application ID of the Databricks Service Principal.
	//
	// This field is only required for Workload Identity Federation and should
	// be empty for Account-wide token federation.
	ClientID string

	// AccountID is the account ID of the Databricks Account. This field is
	// only required for Account-wide token federation.
	AccountID string

	// Host is the host of the Databricks account or workspace.
	Host string

	// TokenEndpointProvider returns the token endpoint for the Databricks OIDC
	// application.
	TokenEndpointProvider func(ctx context.Context) (*u2m.OAuthAuthorizationServer, error)

	// Audience is the audience of the Databricks OIDC application.
	// This is only used for Workspace level tokens.
	Audience string

	// IDTokenProvider returns the IDToken to be used for the token exchange.
	IDTokenProvider IDTokenProvider
}

DatabricksOIDCTokenProviderConfig is the configuration for a Databricks OIDC TokenProvider.

type IDToken

type IDToken struct {
	Value string
}

IDToken represents an OIDC ID token that can be exchanged for a Databricks access token.

type IDTokenProvider

type IDTokenProvider interface {
	IDToken(ctx context.Context, audience string) (*IDToken, error)
}

IDTokenProvider is anything that returns an IDToken given an audience.

func NewAzureDevOpsIDTokenProvider

func NewAzureDevOpsIDTokenProvider(client *httpclient.ApiClient) (IDTokenProvider, error)

NewAzureDevOpsIDTokenProvider returns a new IDTokenProvider that retrieves an IDToken from an Azure DevOps environment.

This IDTokenProvider is only valid when running in Azure DevOps Pipelines.

func NewEnvIDTokenProvider

func NewEnvIDTokenProvider(env string) IDTokenProvider

NewEnvIDTokenProvider returns an IDTokenProvider that reads the IDtoken from environment variable env.

Note that the IDTokenProvider does not cache the token and will read the token from environment variable env each time.

func NewFileTokenProvider

func NewFileTokenProvider(path string) IDTokenProvider

NewFileTokenProvider returns an IDTokenProvider that reads the ID token from a file. The file should contain a single line with the token.

func NewGithubIDTokenProvider

func NewGithubIDTokenProvider(client *httpclient.ApiClient, actionsIDTokenRequestURL, actionsIDTokenRequestToken string) IDTokenProvider

NewGithubIDTokenProvider returns a new IDTokenProvider that retrieves an IDToken from the Github Actions environment. This IDTokenProvider is only valid when running in Github Actions with OIDC enabled.

type IDTokenProviderFn

type IDTokenProviderFn func(ctx context.Context, audience string) (*IDToken, error)

IDTokenProviderFn is an adapter to allow the use of ordinary functions as IDTokenProvider.

Example:

   ts := IDTokenProviderFn(func(ctx context.Context, aud string) (*IDToken, error) {
		return &IDToken{}, nil
   })

func (IDTokenProviderFn) IDToken

func (fn IDTokenProviderFn) IDToken(ctx context.Context, audience string) (*IDToken, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL