naisapi

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package keyring is a simple wrapper that adds timeouts to the zalando/go-keyring package "Borrowed" with ❤️ from https://github.com/cli/cli/blob/17af24e147629aa1aed2546e87e9323aeabf4c8c/internal/keyring/keyring.go

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAuthenticated = errors.New("not authenticated")

Functions

func AddTeamMember

func AddTeamMember(ctx context.Context, teamSlug, email string, role gql.TeamMemberRole) error

func GetAllTeamSlugs

func GetAllTeamSlugs(ctx context.Context) ([]string, error)

func GetAllTeams

func GetAllTeams(ctx context.Context) (*gql.TeamsResponse, error)

func GetUserEmails

func GetUserEmails(ctx context.Context) ([]string, error)

func GetUsers

func GetUsers(ctx context.Context) (*gql.UsersResponse, error)

func GraphqlClient

func GraphqlClient(ctx context.Context) (graphql.Client, error)

func IsConsoleAdmin

func IsConsoleAdmin(ctx context.Context) bool

IsConsoleAdmin checks if the authenticated user is a Console admin or not.

func Login

func Login(ctx context.Context, out cli.Output) error

Login initiates the OAuth2 authorization code flow to authenticate the user. The user's secret is saved in the system keyring. See AuthenticatedUser for primitives that allows interacting with the Nais API on behalf of the authenticated user.

func Logout

func Logout(ctx context.Context, out cli.Output) error

Logout deletes the user's secret from the system keyring and triggers logout at the identity provider.

func PullSchema

func PullSchema(ctx context.Context, _ *flag.Schema) (string, error)

func RemoveTeamMember

func RemoveTeamMember(ctx context.Context, teamSlug, email string) error

func StartProxy

func StartProxy(ctx context.Context, out cli.Output, flags *flag.Proxy) error

Types

type AuthenticatedUser

type AuthenticatedUser struct {
	oauth2.TokenSource
	ConsoleHost string
}

AuthenticatedUser represents the authenticated user. It provides primitives for interacting with the Nais API on behalf of the user. The primitives may return an ErrNotAuthenticated if the user has invalid or expired credentials, in which case the user must reauthenticate through Login.

func GetAuthenticatedUser

func GetAuthenticatedUser(ctx context.Context) (*AuthenticatedUser, error)

GetAuthenticatedUser may return an ErrNotAuthenticated if the user has invalid or expired credentials, in which case the user must reauthenticate through Login.

func (*AuthenticatedUser) HTTPClient

func (a *AuthenticatedUser) HTTPClient(ctx context.Context) *http.Client

HTTPClient returns a http.Client configured with the user's access token.

func (*AuthenticatedUser) RoundTripper

func (a *AuthenticatedUser) RoundTripper(base http.RoundTripper) http.RoundTripper

RoundTripper returns a http.RoundTripper configured with the user's access token.

func (*AuthenticatedUser) SetAuthorizationHeader

func (a *AuthenticatedUser) SetAuthorizationHeader(headers http.Header) error

SetAuthorizationHeader sets the "Authorization" header with the user's access token.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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