common

package
v0.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UILabel is the name of the label key inside of UI config maps.
	UILabel = "label"
	// UIDescription is the name of the description key inside of UI config maps.
	UIDescription = "description"
)
View Source
const (
	DurationRegexpString = "^([0-9]+d)?([0-9]+h)?([0-9]+m)?([0-9]+s)?$"
)

Variables

This section is empty.

Functions

func ConvertTokenToIdentityUnsafe

func ConvertTokenToIdentityUnsafe(tok string) (*ga4gh.Identity, error)

ConvertTokenToIdentityUnsafe unsafely converts a token to an identity.

func ExtractVariables

func ExtractVariables(v string) (map[string]bool, error)

ExtractVariables returns a map of variable names found within an input string.

func FilterStringsByPrefix

func FilterStringsByPrefix(in []string, prefix string) []string

FilterStringsByPrefix filters returns only strings that do NOT have a given prefix.

func FutureTimestamp

func FutureTimestamp(ttl time.Duration) string

func GenerateGUID

func GenerateGUID() string

func GetNowInUnix

func GetNowInUnix() int64

GetNowInUnix returns Unix timestamp in seconds, equivalent to `date "+%s"`.

func GetNowInUnixNano

func GetNowInUnixNano() float64

GetNowInUnixNano returns Unix timestamp equivalent to `date "+%s.%N"`.

func GetOIDCTokenVerifier

func GetOIDCTokenVerifier(ctx context.Context, clientID, issuer string) (*oidc.IDTokenVerifier, error)

GetOIDCTokenVerifier returns an OIDC token verifier for a particular client.

func HasUserinfoClaims

func HasUserinfoClaims(id *ga4gh.Identity) bool

HasUserinfoClaims checks if /userinfo endpoint needs to be called to fetch additional claims for a particular identity.

func IsAudience

func IsAudience(token *ga4gh.Identity, clientID, self string) bool

IsAudience returns true if the token's "azp" or "aud" contains the self string or clientID.

func IsImageURL

func IsImageURL(src string) bool

IsImageURL returns true if the format of the string appears to be a URL image.

func IsLocale

func IsLocale(name string) bool

IsLocale returns true if the "name" provided is a locale name as per https://tools.ietf.org/html/bcp47.

func IsTimeZone

func IsTimeZone(name string) bool

IsTimeZone returns true if the "name" provided is an IANA Time Zone name.

func IsURL

func IsURL(v string) bool

IsURL returns true if the format of the string appears to be a fully qualified URL

func JoinNonEmpty

func JoinNonEmpty(in []string, separator string) string

JoinNonEmpty filters empty strings and joins remainder together.

func KeyTTL

func KeyTTL(maxRequestedTTL time.Duration, numKeys int) time.Duration

func ListContains

func ListContains(list []string, find string) bool

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

func ParseDuration

func ParseDuration(d string, def time.Duration) (time.Duration, error)

func ParseGUID

func ParseGUID(in string) (uuid.UUID, error)

func ParseNegDuration

func ParseNegDuration(d string, def time.Duration) (time.Duration, error)

ParseNegDuration parses durations that may sometimes be negative in value.

func ParseSeconds

func ParseSeconds(d string) (time.Duration, error)

ParseSeconds returns a duration from a numeric string in seconds

func PastTimestamp

func PastTimestamp(ttl time.Duration) string

PastTimestamp returns a timestamp string a given duration in the past.

func QuoteSplit

func QuoteSplit(str, separator string, stripQuotes bool) []string

QuoteSplit is similiar to strings.Split() but doesn't split within double-quotes.

func ReplaceVariables

func ReplaceVariables(v string, args map[string]string) (string, error)

ReplaceVariables replaces all substrings of the form "${var-name}" based on args like {"var-name":"var-value"}.

func RequestAbstractPath

func RequestAbstractPath(r *http.Request) string

func TimestampString

func TimestampString(epoch int64) string

TimestampString returns a RFC3339 date/time string.

func ToTitle

func ToTitle(str string) string

ToTitle does some auto-formatting on camel-cased or snake-cased strings to make them look like titles.

func TokenUserID

func TokenUserID(token *ga4gh.Identity, maxLength int) string

TokenUserID returns an user identifier for a given token.

func TtlString

func TtlString(ttl time.Duration) string

func UserID

func UserID(subject, issuer string, maxLength int) string

UserID returns an user identifier that specifies a subject within an issuer.

func VerifyTokenWithKey

func VerifyTokenWithKey(publicKey *rsa.PublicKey, tok string) error

VerifyTokenWithKey verifies the signature of a token given a public key.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL