Imports #
"errors"
"flag"
"fmt"
"net/url"
"os"
"strconv"
"time"
"errors"
"flag"
"fmt"
"net/url"
"os"
"strconv"
"time"
OAuth Provider
type OAuthProvider interface {
Name() string
AuthURL() string
TokenURL() string
AppCallbackURL() string
AppTokenEndpoint() string
ClientID() string
ClientSecret() string
}
Config
type Config struct {
Version string
Port int
EnableTLS bool
CertFile string
KeyFile string
APIRate int
APIBurst int
SolverTimeout time.Duration
OAuth bool
JWTSecret string
JWTTokenValidity time.Duration
OAuthProviders map[string]OAuthProvider
}
Github OAuth provider
type GithubProvider struct {
ProviderName string
ProviderAuthURL string
ProviderTokenURL string
CallbackURL string
AppClientId string
AppClientSecret string
}
Returns callback URL where Github will redirect the user
func (p GithubProvider) AppCallbackURL() string
Returns code<>token exchange URL where client can exchange code for JWT token
func (p GithubProvider) AppTokenEndpoint() string
Returns URL where client can authenticate with the OAuth Provider
func (p GithubProvider) AuthURL() string
Returns Client ID
func (p GithubProvider) ClientID() string
Returns Client Secret
func (p GithubProvider) ClientSecret() string
Load configuration from command line and environment Returns Configuration and list of load errors TODO: JSON config
func LoadConfig() (Config, []error)
Returns Name
func (p GithubProvider) Name() string
Constructor with defaults
func NewConfig() Config
func StripHost(raw string) (string, error)
Returns URl where app can exchange client code for a token
func (p GithubProvider) TokenURL() string
Validates configuration. Returns if configuration is valid or list of validation errors
func (cfg *Config) ValidateConfig() (bool, []error)
Returns value of env variable or default if not set
func envOrDefault(env string, def string) string
Check if string is valid URL
func isValidURL(s string) bool