Documentation
¶
Index ¶
- func DefaultAuth(cfg *config.Configuration) (rt http.RoundTripper, err error)
- func KeyAuth(cfg *config.Configuration) (http.RoundTripper, error)
- func NoAuth() (rt http.RoundTripper, err error)
- func SetupAuth(cfg *config.Configuration) (rt http.RoundTripper, err error)
- func TokenAuth(cfg *config.Configuration) (http.RoundTripper, error)
- type Credentials
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuth ¶
func DefaultAuth(cfg *config.Configuration) (rt http.RoundTripper, err error)
DefaultAuth will search for a valid service account key or token in several locations. It will first try to use the key flow, by looking into the variables STACKIT_SERVICE_ACCOUNT_KEY, STACKIT_SERVICE_ACCOUNT_KEY_PATH, STACKIT_PRIVATE_KEY and STACKIT_PRIVATE_KEY_PATH. If the keys cannot be retrieved, it will check the credentials file located in STACKIT_CREDENTIALS_PATH, if specified, or in $HOME/.stackit/credentials.json as a fallback. If the key are found and are valid, the KeyAuth flow is used. If the key flow cannot be used, it will try to find a token in the STACKIT_SERVICE_ACCOUNT_TOKEN. If not present, it will search in the credentials file. If the token is found, the TokenAuth flow is used. DefaultAuth returns an http.RoundTripper that can be used to make authenticated requests. In case the token is not found, DefaultAuth fails.
func KeyAuth ¶
func KeyAuth(cfg *config.Configuration) (http.RoundTripper, error)
KeyAuth configures the key flow and returns an http.RoundTripper that can be used to make authenticated requests using an access token The KeyFlow requires a service account key and a private key.
If the private key is not provided explicitly, KeyAuth will check if there is one included in the service account key and use that one. An explicitly provided private key takes precedence over the one on the service account key.
func NoAuth ¶
func NoAuth() (rt http.RoundTripper, err error)
NoAuth configures a flow without authentication and returns an http.RoundTripper that can be used to make unauthenticated requests
func SetupAuth ¶
func SetupAuth(cfg *config.Configuration) (rt http.RoundTripper, err error)
SetupAuth sets up authentication based on the configuration. The different options are custom authentication, no authentication, explicit key flow, explicit token flow or default authentication
func TokenAuth ¶
func TokenAuth(cfg *config.Configuration) (http.RoundTripper, error)
TokenAuth configures the token flow and returns an http.RoundTripper that can be used to make authenticated requests using a token