Documentation
¶
Index ¶
- Variables
- func AuthorizationCodeGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, ...) error
- func Authorize(clientConfig oauth2.ClientConfig, hc *http.Client) error
- func ClientCredentialsGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, ...) error
- func ImplicitGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, ...) error
- func JWTBearerGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, ...) error
- func LogAssertion(request oauth2.Request)
- func LogAuthMethod(config oauth2.ClientConfig)
- func LogJson(value interface{})
- func LogRequest(r oauth2.Request)
- func LogRequestAndResponse(request oauth2.Request, response interface{})
- func LogRequestAndResponseln(request oauth2.Request, response interface{})
- func LogRequestln(request oauth2.Request)
- func LogTokenPayload(response oauth2.TokenResponse)
- func LogTokenPayloadln(response oauth2.TokenResponse)
- func PasswordGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, ...) error
- func PromptBool(name string) (ret bool)
- func PromptForClientConfig(client oauth2.ClientConfig, server oauth2.ServerConfig) oauth2.ClientConfig
- func PromptMultiStringSlice(name string, options []string) (ret []string)
- func PromptString(name string) (ret string)
- func PromptStringSlice(name string, options []string) (ret string)
- func RefreshTokenGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, ...) error
- type Config
Constants ¶
This section is empty.
Variables ¶
View Source
var OAuth2Cmd = &cobra.Command{ Use: "oauthc [issuer url or json config file]", Short: "User-friendly command-line for OAuth2", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { var ( config Config data []byte err error ) if data, err = os.ReadFile(args[0]); err == nil { if err = json.Unmarshal(data, &config); err != nil { pterm.Error.PrintOnError(err) os.Exit(1) } if err := mergo.Merge(&cconfig, config.ToClientConfig()); err != nil { pterm.Error.PrintOnError(err) os.Exit(1) } } else { cconfig.IssuerURL = strings.TrimSuffix(args[0], oauth2.OpenIDConfigurationPath) } hc := &http.Client{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: cconfig.Insecure, }, }, } if err := Authorize(cconfig, hc); err != nil { var oauth2Error *oauth2.Error if errors.As(err, &oauth2Error) { switch oauth2Error.Hint { case "Clients must include a code_challenge when performing the authorize code flow, but it is missing.": pterm.Warning.Println("Authorization server enforces PKCE. Use --pkce flag.") } } pterm.Error.PrintOnError(err) os.Exit(1) } }, }
Functions ¶
func AuthorizationCodeGrantFlow ¶
func AuthorizationCodeGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, hc *http.Client) error
func ClientCredentialsGrantFlow ¶
func ClientCredentialsGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, hc *http.Client) error
func ImplicitGrantFlow ¶
func ImplicitGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, hc *http.Client) error
func JWTBearerGrantFlow ¶
func JWTBearerGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, hc *http.Client) error
func LogAssertion ¶
func LogAuthMethod ¶
func LogAuthMethod(config oauth2.ClientConfig)
func LogRequest ¶
func LogRequestAndResponse ¶
func LogRequestAndResponseln ¶
func LogRequestln ¶
func LogTokenPayload ¶
func LogTokenPayload(response oauth2.TokenResponse)
func LogTokenPayloadln ¶
func LogTokenPayloadln(response oauth2.TokenResponse)
func PasswordGrantFlow ¶
func PasswordGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, hc *http.Client) error
func PromptBool ¶
func PromptForClientConfig ¶
func PromptForClientConfig(client oauth2.ClientConfig, server oauth2.ServerConfig) oauth2.ClientConfig
func PromptMultiStringSlice ¶
func PromptString ¶
func PromptStringSlice ¶
func RefreshTokenGrantFlow ¶
func RefreshTokenGrantFlow(clientConfig oauth2.ClientConfig, serverConfig oauth2.ServerConfig, hc *http.Client) error
Types ¶
type Config ¶
type Config struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
OpenIDDiscoveryEndpoint string `json:"openid_discovery_endpoint"`
}
func (Config) ToClientConfig ¶
func (c Config) ToClientConfig() oauth2.ClientConfig
Click to show internal directories.
Click to hide internal directories.