liboidcagent

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 11 Imported by: 2

README

liboidcagent

liboidcagent is a go library for requesting OpenID Connect access token from oidc-agent from within go applications.

Documentation can be found at https://indigo-dc.gitbook.io/oidc-agent/api/api-go

Tests

The testing the library requires a working oidc-agent setup:

oidc-add <account shortname>
export OIDC_AGENT_ACCOUNT=<account shortname>
export OIDC_AGENT_ISSUER=<issuer of the account>
go test -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAccessToken

func GetAccessToken(req TokenRequest) (string, error)

GetAccessToken gets an access token

func GetConfiguredAccounts added in v0.3.0

func GetConfiguredAccounts() (accounts []string, err error)

GetConfiguredAccounts returns a list of all accounts which are configured for oidc-agent

func GetLoadedAccounts added in v0.3.0

func GetLoadedAccounts() (accountNames []string, err error)

GetLoadedAccounts returns a list of all accounts which are currently loaded by oidc-agent

func GetMytoken added in v0.4.0

func GetMytoken(req MytokenRequest) (string, error)

GetMytoken gets an mytoken

Types

type AccountInfoResponse added in v0.5.0

type AccountInfoResponse map[string]IssuerInfo

AccountInfoResponse holds information about the available accounts and issuers

func GetAccountInfos added in v0.5.0

func GetAccountInfos() (info AccountInfoResponse, err error)

GetAccountInfos returns information about all issuers and their available account names and if those are loaded or not

type IssuerInfo added in v0.5.0

type IssuerInfo struct {
	// Indicates whether a public client for this issuer is available or not
	HasPubClient bool `json:"pubclient"`
	// Maps account short names to a bool indicating if this account is currently loaded or not
	Accounts map[string]bool `json:"accounts"`
}

IssuerInfo is a type for holding information about a supported issuer

type MytokenRequest added in v0.4.0

type MytokenRequest struct {
	// ShortName that should be used
	ShortName string
	// A mytoken profile describing the properties of the requested mytoken
	MytokenProfile string
	// A string describing the requesting application (i.e. its name). It might
	// be displayed to the user, if the request must be confirmed or an account
	// configuration loaded.
	ApplicationHint string
}

MytokenRequest is used to request a mytoken from the agent

type MytokenResponse added in v0.4.0

type MytokenResponse struct {
	mytoken.MytokenResponse
	OIDCIssuer    string
	MytokenIssuer string
	// The time when the token expires
	ExpiresAt time.Time
}

MytokenResponse is a parse response from the oidc-agent compatible with the struct from the mytoken api, but with ExpiresAt set instead of ExpiresIn

func GetMytokenResponse added in v0.4.0

func GetMytokenResponse(req MytokenRequest) (resp MytokenResponse, err error)

GetMytokenResponse gets a mytoken response from the agent

type OIDCAgentError added in v0.2.0

type OIDCAgentError struct {
	// contains filtered or unexported fields
}

OIDCAgentError is an error type used for returning errors

func (OIDCAgentError) Error added in v0.2.0

func (e OIDCAgentError) Error() string

func (OIDCAgentError) ErrorWithHelp added in v0.2.0

func (e OIDCAgentError) ErrorWithHelp() string

ErrorWithHelp returns a string combining the error message and the help message (if available).

func (OIDCAgentError) Help added in v0.2.0

func (e OIDCAgentError) Help() string

Help returns a help message if available. This help message helps the user to solve the problem. If a help message is available it SHOULD be displayed to the user. One can use ErrorWithHelp to obtain both.

type TokenRequest

type TokenRequest struct {
	// ShortName that should be used (Can be omitted if IssuerURL is specified)
	ShortName string
	// IssuerURL for which an access token should be obtained (Can be omitted
	// if ShortName is specified)
	IssuerURL string
	// MinValidPeriod specifies how long the access token should be valid at
	// least. The time is given in seconds. Default is 0.
	MinValidPeriod uint64
	// The scopes for the requested access token
	Scopes []string
	// The audiences for the requested access token
	Audiences []string
	// A string describing the requesting application (i.e. its name). It might
	// be displayed to the user, if the request must be confirmed or an account
	// configuration loaded.
	ApplicationHint string
}

TokenRequest is used to request an access token from the agent

type TokenResponse

type TokenResponse struct {
	// The access token
	Token string
	// The provider that issued the token
	Issuer string
	// The time when the token expires
	ExpiresAt time.Time
}

TokenResponse is a parsed response from the oidc-agent

func GetTokenResponse

func GetTokenResponse(req TokenRequest) (resp TokenResponse, err error)

GetTokenResponse gets a TokenResponse

Jump to

Keyboard shortcuts

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