Documentation ¶
Index ¶
- func FillForm(config HTMLFormConfig, page *html.Node, userName, password string) (action string, values url.Values, err error)
- func FormAuth(cfg HTMLFormConfig, authURL string, userName, password string) *url.URL
- func ReadPage(url string) (*html.Node, []*http.Cookie, error)
- func RefreshToken(clientID, clientSecret, refreshToken, tokenURL string) (oauth2.Token, error)
- type Config
- type Data
- type FieldConfig
- type HTMLFormConfig
- type Protocol
- func (p *Protocol) DecodeCfg(in interface{}) (interface{}, error)
- func (p *Protocol) GetAuthURL(s ServerData) string
- func (p *Protocol) GetConfig() Config
- func (p *Protocol) GetToken(request proto.TokenRequest) (string, interface{}, error)
- func (p *Protocol) GetTokenURL(s ServerData) string
- func (p *Protocol) InitSetupWizard(name string, profileName string, profile cfg.Profile) ([]proto.SetupStep, *cobra.Command)
- func (p *Protocol) Refresh(tok *TokenData, s ServerData) error
- func (p *Protocol) SetCfg(user, common cfg.Remote)
- func (p *Protocol) TooClose(accessToken string, serverData ServerData) bool
- func (p *Protocol) Validate(accessToken string, serverData ServerData) bool
- type ServerData
- type ServerProfile
- type TokenData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FillForm ¶
func FillForm(config HTMLFormConfig, page *html.Node, userName, password string) (action string, values url.Values, err error)
FillForm processes the form, prompts the user for field values, and returns the form to be submitted
func FormAuth ¶
func FormAuth(cfg HTMLFormConfig, authURL string, userName, password string) *url.URL
FormAuth retrieves a login form from the authURL, parses it, asks credentials, submits the form, and if everything goes fine, returns the redirect URL
Types ¶
type Config ¶
type Config struct { ServerProfile `yaml:",inline" mapstructure:",squash"` Profile string `yaml:"profile,omitempty" mapstructure:"profile,omitempty"` ClientID string `yaml:"clientid" mapstructure:"clientid"` ClientSecret string CallbackURL string `yaml:"callbackurl,omitempty" mapstructure:"callbackurl,omitempty"` }
Config includes the server profile and contains user creds
type FieldConfig ¶
type FieldConfig struct { Input string `json:"input" yaml:"input"` // If non-empty, will ask for value Prompt string `json:"prompt,omitempty" yaml:"prompt,omitempty"` Password bool `json:"password" yaml:"password"` // If non-empty, the default value Value string `json:"value,omitempty" yaml:"value,omitempty"` }
FieldConfig describes an HTML field in the HTML form
type HTMLFormConfig ¶
type HTMLFormConfig struct { // Form ID ID string `json:"id,omitempty" yaml:"id,omitempty"` // Which field in Fields is the password field PasswordField string `json:"passwordField,omitempty" yaml:"passwordField,omitempty"` // Which field in Fields is the username field UsernameField string `json:"usernameField,omitempty" yaml:"usernameField,omitempty"` Fields []FieldConfig `json:"fields,omitempty" yaml:"fields,omitempty"` }
HTMLFormConfig defines an HTP login form structure
type Protocol ¶
Protocol contains the oidc config, default congfig, and tokens
func (*Protocol) GetAuthURL ¶
func (p *Protocol) GetAuthURL(s ServerData) string
GetAuthURL returns the auth URL on the auth server
func (*Protocol) GetToken ¶
func (p *Protocol) GetToken(request proto.TokenRequest) (string, interface{}, error)
GetToken gets a token
func (*Protocol) GetTokenURL ¶
func (p *Protocol) GetTokenURL(s ServerData) string
GetTokenURL retutrns the token URL on the auth server
func (*Protocol) InitSetupWizard ¶
func (p *Protocol) InitSetupWizard(name string, profileName string, profile cfg.Profile) ([]proto.SetupStep, *cobra.Command)
InitSetupWizard initializes the setup wizard for oidc
func (*Protocol) Refresh ¶
func (p *Protocol) Refresh(tok *TokenData, s ServerData) error
Refresh refreshes the token
type ServerData ¶
type ServerData struct { AuthorizationEndpoint string `json:"authorization_endpoint"` TokenEndpoint string `json:"token_endpoint"` IntrospectionEndpoint string `json:"token_introspection_endpoint"` UserInfoEndpoint string `json:"userinfo_endpoint"` EndSessionEndpoint string `json:"end_session_endpoint"` JWKSUri string `json:"jwks_uri"` }
ServerData contains the OIDC server information
func GetServerData ¶
func GetServerData(url string) (ServerData, error)
GetServerData retrieves server data from the auth server
type ServerProfile ¶
type ServerProfile struct { URL string `yaml:"url,omitempty" mapstructure:"url,omitempty"` TokenAPI string `yaml:"tokenapi,omitempty" mapstructure:"tokenapi,omitempty"` AuthAPI string `yaml:"authapi,omitempty" mapstructure:"authapi,omitempty"` Form *HTMLFormConfig `yaml:"form,omitempty" mapstructure:"form,omitempty"` Insecure bool PasswordGrant *bool `yaml:"passwordgrant,omitempty"` RefreshOnly *bool `yaml:"refreshonly,omitempty"` AdditionalScopes []string `yaml:"additionalscopes,omitempty"` }
ServerProfile defines an OIDC auth server
func (ServerProfile) Merge ¶
func (s ServerProfile) Merge(in ServerProfile) ServerProfile
Merge sets any unset field in s from in, and returns the merged copy
type TokenData ¶
TokenData contains the access and refresh token with username
func (TokenData) FormatToken ¶
func (t TokenData) FormatToken(out proto.OutputOption) string
FormatToken converts token to string based on the output options