Documentation
¶
Index ¶
- Variables
- func Capitalize(word string) string
- func CheckClaim(logger *zap.Logger, user *models.UserContext, claimName string, ...) bool
- func ContainsSubString(value string, list []string) bool
- func DecodeKeyPairs(list []string) (map[string]string, error)
- func DefaultTo(v, d string) string
- func DialAddress(location *url.URL) string
- func FileExists(filename string) bool
- func GenerateHmac(req *http.Request, encKey string) (string, error)
- func GetHashKey(token string) string
- func GetRefreshedToken(ctx context.Context, conf *oauth2.Config, httpClient *http.Client, ...) (jwt.JSONWebToken, string, string, time.Time, time.Duration, error)
- func GetRequestHostURL(req *http.Request) string
- func GetWithin(expires time.Time, within float64) time.Duration
- func HasAccess(need map[string]bool, have []string, all bool) bool
- func IsUpgradedConnection(req *http.Request) bool
- func IsValidHTTPMethod(method string) bool
- func MergeMaps(dest, source map[string]string) map[string]string
- func NewOAuth2Config(clientID string, clientSecret string, authURL string, tokenURL string, ...) func(redirectionURL string) *oauth2.Config
- func ParseRefreshToken(rawRefreshToken string) (*jwt.Claims, error)
- func PrintError(message string, args ...interface{}) cli.ExitCoder
- func RealIP(req *http.Request) string
- func ToHeader(v string) string
- func TransferBytes(src io.Reader, dest io.Writer, wg *sync.WaitGroup) (int64, error)
- func TryDialEndpoint(location *url.URL) (net.Conn, error)
- func TryUpdateConnection(req *http.Request, writer http.ResponseWriter, endpoint *url.URL) error
- func VerifyOIDCTokens(ctx context.Context, provider *oidc3.Provider, clientID string, ...) (*oidc3.IDToken, *oidc3.IDToken, error)
- func VerifyToken(ctx context.Context, provider *oidc3.Provider, rawToken string, ...) (*oidc3.IDToken, error)
- func WithOAuthURI(baseURI string, oauthURI string) func(uri string) string
Constants ¶
This section is empty.
Variables ¶
var ( AllHTTPMethods = []string{ http.MethodDelete, http.MethodGet, http.MethodHead, http.MethodOptions, http.MethodPatch, http.MethodPost, http.MethodPut, http.MethodTrace, } )
Functions ¶
func Capitalize ¶
Capitalize capitalizes the first letter of a word.
func CheckClaim ¶
func CheckClaim( logger *zap.Logger, user *models.UserContext, claimName string, match *regexp.Regexp, resourceURL string, ) bool
CheckClaim checks whether claim in userContext matches claimName, match. It can be String or Strings claim.
func ContainsSubString ¶
func DialAddress ¶
DialAddress extracts the dial address from the url.
func FileExists ¶
func GetHashKey ¶
GetHashKey returns a hash of the encoded jwt token.
func GetRefreshedToken ¶
func GetRefreshedToken( ctx context.Context, conf *oauth2.Config, httpClient *http.Client, oldRefreshToken string, ) (jwt.JSONWebToken, string, string, time.Time, time.Duration, error)
GetRefreshedToken attempts to refresh the access token, returning the parsed token, optionally with a renewed refresh token and the time the access and refresh tokens expire
NOTE: we may be able to extract the specific (non-standard) claim refresh_expires_in and refresh_expires from response.RawBody. When not available, keycloak provides us with the same (for now) expiry value for ID token.
func GetRequestHostURL ¶
func GetWithin ¶
GetWithin calculates a duration of x percent of the time period, i.e. something expires in 1 hours, get me a duration within 80%.
func IsUpgradedConnection ¶
func IsValidHTTPMethod ¶
func NewOAuth2Config ¶
func PrintError ¶
PrintError display the command line usage and error.
func TransferBytes ¶
TransferBytes transfers bytes between the sink and source.
func TryDialEndpoint ¶
TryDialEndpoint dials the upstream endpoint via plain HTTP.
func TryUpdateConnection ¶
TryUpdateConnection attempt to upgrade the connection to a http pdy stream.
func VerifyOIDCTokens ¶
func VerifyToken ¶
Types ¶
This section is empty.