jx: github.com/jenkins-x/jx/pkg/auth Index | Files | Directories

package auth

import "github.com/jenkins-x/jx/pkg/auth"

Index

Package Files

auth_config.go auth_config_service.go constants.go file_config_saver.go interfaces.go memory_config_saver.go server.go types.go user_auth.go vault_config_saver.go

Constants

const (
    // AddonAuthConfigFile config file for addon auth credentials
    AddonAuthConfigFile = "addonAuth.yaml"
    // JenkinsAuthConfigFile config file for Jenkins auth credentials
    JenkinsAuthConfigFile = "jenkinsAuth.yaml"
    // IssuesAuthConfigFile config file for Issues auth credentials
    IssuesAuthConfigFile = "issuesAuth.yaml"
    // CreateAuthUserFromEnvironment config file for chat auth credentials
    ChatAuthConfigFile = "chatAuth.yaml"
    // GitAuthConfigFile config file for git auth credentials
    GitAuthConfigFile = "gitAuth.yaml"
    // ChartmuseumAuthConfigFile config file for chartmusuem auth credentials
    ChartmuseumAuthConfigFile = "chartmuseumAuth.yaml"
)
const (
    DefaultUsername = "dummy"
)

func ApiTokenEnv Uses

func ApiTokenEnv(prefix string) string

ApiTokenEnv builds the api token environment variable name

func BearerTokenEnv Uses

func BearerTokenEnv(prefix string) string

BearerTokenEnv builds the bearer token environment variable name

func UsernameEnv Uses

func UsernameEnv(prefix string) string

UsernameEnv builds the username environment variable name

type AuthConfig Uses

type AuthConfig struct {
    Servers []*AuthServer `json:"servers"`

    DefaultUsername  string `json:"defaultusername"`
    CurrentServer    string `json:"currentserver"`
    PipeLineUsername string `json:"pipelineusername"`
    PipeLineServer   string `json:"pipelineserver"`
}

func (*AuthConfig) AddServer Uses

func (c *AuthConfig) AddServer(server *AuthServer)

func (*AuthConfig) CurrentAuthServer Uses

func (c *AuthConfig) CurrentAuthServer() *AuthServer

CurrentAuthServer returns the current AuthServer configured in the configuration

func (*AuthConfig) CurrentUser Uses

func (c *AuthConfig) CurrentUser(server *AuthServer, inCluster bool) *UserAuth

func (*AuthConfig) DeleteServer Uses

func (c *AuthConfig) DeleteServer(url string)

DeleteServer deletes the server for the given URL and updates the current server if is the same with the deleted server

func (*AuthConfig) EditUserAuth Uses

func (c *AuthConfig) EditUserAuth(serverLabel string, auth *UserAuth, defaultUserName string, editUser, batchMode bool, fn PrintUserFn, in terminal.FileReader, out terminal.FileWriter, outErr io.Writer) error

EditUserAuth Lets the user input/edit the user auth

func (*AuthConfig) FindUserAuth Uses

func (c *AuthConfig) FindUserAuth(serverURL string, username string) *UserAuth

FindUserAuth finds the auth for the given user name if no username is specified and there is only one auth then return that else nil

func (*AuthConfig) FindUserAuths Uses

func (c *AuthConfig) FindUserAuths(serverURL string) []*UserAuth

func (*AuthConfig) GetOrCreateServer Uses

func (c *AuthConfig) GetOrCreateServer(url string) *AuthServer

func (*AuthConfig) GetOrCreateServerName Uses

func (c *AuthConfig) GetOrCreateServerName(url string, name string, kind string) *AuthServer

func (*AuthConfig) GetOrCreateUserAuth Uses

func (c *AuthConfig) GetOrCreateUserAuth(url string, username string) *UserAuth

func (*AuthConfig) GetPipelineAuth Uses

func (c *AuthConfig) GetPipelineAuth() (*AuthServer, *UserAuth)

GetPipelineAuth returns the current pipline server and user authentication

func (*AuthConfig) GetServer Uses

func (c *AuthConfig) GetServer(url string) *AuthServer

GetServerByName returns the server for the given URL or null if its not found

func (*AuthConfig) GetServerByKind Uses

func (c *AuthConfig) GetServerByKind(kind string) *AuthServer

GetServerByKind returns the server for the given kind or null if its not found

func (*AuthConfig) GetServerByName Uses

func (c *AuthConfig) GetServerByName(name string) *AuthServer

GetServerByName returns the server for the given name or null if its not found

func (*AuthConfig) GetServerNames Uses

func (c *AuthConfig) GetServerNames() []string

GetServerNames returns the name of the server currently in the configuration

func (*AuthConfig) GetServerURLs Uses

func (c *AuthConfig) GetServerURLs() []string

GetServerURLs returns the server URLs currently in the configuration

func (*AuthConfig) IndexOfServerName Uses

func (c *AuthConfig) IndexOfServerName(name string) int

func (*AuthConfig) PickOrCreateServer Uses

func (c *AuthConfig) PickOrCreateServer(fallbackServerURL string, serverURL string, message string, batchMode bool, in terminal.FileReader, out terminal.FileWriter, outErr io.Writer) (*AuthServer, error)

PickOrCreateServer picks the server to use defaulting to the current server

func (*AuthConfig) PickServer Uses

func (c *AuthConfig) PickServer(message string, batchMode bool, in terminal.FileReader, out terminal.FileWriter, outErr io.Writer) (*AuthServer, error)

func (*AuthConfig) PickServerUserAuth Uses

func (c *AuthConfig) PickServerUserAuth(server *AuthServer, message string, batchMode bool, org string, in terminal.FileReader, out terminal.FileWriter, errOut io.Writer) (*UserAuth, error)

PickServerAuth Pick the servers auth

func (*AuthConfig) SetUserAuth Uses

func (c *AuthConfig) SetUserAuth(url string, auth *UserAuth)

func (*AuthConfig) UpdatePipelineServer Uses

func (c *AuthConfig) UpdatePipelineServer(server *AuthServer, user *UserAuth)

UpdatePipelineServer updates the pipeline server in the configuration

type AuthConfigService Uses

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

AuthConfigService implements the generic features of the ConfigService because we don't have superclasses

func NewAuthConfigService Uses

func NewAuthConfigService(saver ConfigSaver) *AuthConfigService

NewAuthConfigService generates a AuthConfigService with a custom saver. This should not be used directly

func (*AuthConfigService) Config Uses

func (s *AuthConfigService) Config() *AuthConfig

Config gets the AuthConfig from the service

func (*AuthConfigService) DeleteServer Uses

func (s *AuthConfigService) DeleteServer(url string) error

DeleteServer removes the given server from the configuration

func (*AuthConfigService) LoadConfig Uses

func (s *AuthConfigService) LoadConfig() (*AuthConfig, error)

LoadConfig loads the configuration from the users JX config directory

func (*AuthConfigService) SaveConfig Uses

func (s *AuthConfigService) SaveConfig() error

SaveConfig saves the configuration to disk

func (*AuthConfigService) SaveUserAuth Uses

func (s *AuthConfigService) SaveUserAuth(url string, userAuth *UserAuth) error

SaveUserAuth saves the given user auth for the server url

func (*AuthConfigService) SetConfig Uses

func (s *AuthConfigService) SetConfig(c *AuthConfig)

SetConfig sets the AuthConfig object

type AuthServer Uses

type AuthServer struct {
    URL   string      `json:"url"`
    Users []*UserAuth `json:"users"`
    Name  string      `json:"name"`
    Kind  string      `json:"kind"`

    CurrentUser string `json:"currentuser"`
}

func (*AuthServer) CurrentAuth Uses

func (s *AuthServer) CurrentAuth() *UserAuth

CurrentAuth returns the current user auth, otherwise the first one

func (*AuthServer) DeleteUser Uses

func (s *AuthServer) DeleteUser(username string) error

func (*AuthServer) Description Uses

func (s *AuthServer) Description() string

func (*AuthServer) GetUserAuth Uses

func (s *AuthServer) GetUserAuth(username string) *UserAuth

func (*AuthServer) GetUsernames Uses

func (s *AuthServer) GetUsernames() []string

func (*AuthServer) HasUserAuths Uses

func (s *AuthServer) HasUserAuths() bool

HasUserAuths checks if a server has any user auth configured

func (*AuthServer) Label Uses

func (s *AuthServer) Label() string

type ConfigSaver Uses

type ConfigSaver interface {
    // LoadConfig loads the configuration from the users JX config directory
    LoadConfig() (*AuthConfig, error)
    //HasConfigFile() (bool, error)
    // SaveConfig saves the configuration
    SaveConfig(config *AuthConfig) error
}

ConfigSaver is an interface that saves an AuthConfig go:generate pegomock generate github.com/jenkins-x/jx/pkg/auth ConfigSaver -o mocks/auth_interface.go

type ConfigService Uses

type ConfigService interface {
    Config() *AuthConfig
    SetConfig(c *AuthConfig)
    // LoadConfig loads the configuration from the users JX config directory
    LoadConfig() (*AuthConfig, error)
    //HasConfigFile() (bool, error)
    // SaveConfig saves the configuration
    SaveConfig() error
    // SaveUserAuth saves the given user auth for the server url
    SaveUserAuth(url string, userAuth *UserAuth) error
    // DeleteServer removes the given server from the configuration
    DeleteServer(url string) error
}

ConfigService is a service for handing the config of auth tokens

func NewFileAuthConfigService Uses

func NewFileAuthConfigService(filename string) (ConfigService, error)

NewFileAuthConfigService

func NewMemoryAuthConfigService Uses

func NewMemoryAuthConfigService() ConfigService

NewMemoryAuthConfigService creates a new memory based auth service

func NewVaultAuthConfigService Uses

func NewVaultAuthConfigService(secretName string, vaultClient vault.Client) ConfigService

NewVaultAuthConfigService creates a new ConfigService that saves it config to a Vault

type FileAuthConfigSaver Uses

type FileAuthConfigSaver struct {
    FileName string
}

FileAuthConfigSaver is a ConfigSaver that saves its config to the local filesystem

func (*FileAuthConfigSaver) LoadConfig Uses

func (s *FileAuthConfigSaver) LoadConfig() (*AuthConfig, error)

LoadConfig loads the configuration from the users JX config directory

func (*FileAuthConfigSaver) SaveConfig Uses

func (s *FileAuthConfigSaver) SaveConfig(config *AuthConfig) error

SaveConfig saves the configuration to disk

type MemoryAuthConfigSaver Uses

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

MemoryAuthConfigSaver uses memory

func (*MemoryAuthConfigSaver) LoadConfig Uses

func (m *MemoryAuthConfigSaver) LoadConfig() (*AuthConfig, error)

LoadConfig does nothing

func (*MemoryAuthConfigSaver) SaveConfig Uses

func (m *MemoryAuthConfigSaver) SaveConfig(config *AuthConfig) error

SaveConfig updates the config

type PrintUserFn Uses

type PrintUserFn func(username string) error

PrintUserFn prints the use name

type UserAuth Uses

type UserAuth struct {
    Username    string `json:"username"`
    ApiToken    string `json:"apitoken"`
    BearerToken string `json:"bearertoken"`
    Password    string `json:"password,omitempty"`
}

func CreateAuthUserFromEnvironment Uses

func CreateAuthUserFromEnvironment(prefix string) UserAuth

CreateAuthUserFromEnvironment creates a user auth from environment variables

func (*UserAuth) IsInvalid Uses

func (a *UserAuth) IsInvalid() bool

IsInvalid returns true if the user auth has a valid token

type VaultAuthConfigSaver Uses

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

VaultAuthConfigSaver is a ConfigSaver that saves configs to Vault

func (*VaultAuthConfigSaver) LoadConfig Uses

func (v *VaultAuthConfigSaver) LoadConfig() (*AuthConfig, error)

LoadConfig loads the config from the vault

func (*VaultAuthConfigSaver) SaveConfig Uses

func (v *VaultAuthConfigSaver) SaveConfig(config *AuthConfig) error

SaveConfig saves the config to the vault

Directories

PathSynopsis
mocks

Package auth imports 14 packages (graph) and is imported by 25 packages. Updated 2019-09-01. Refresh now. Tools for package owners.