Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GetPermissions = func(visas Visas) []string { log.Debug("parsing permissions from visas") datasets := []string{} log.Debugf("number of visas to check: %d", len(visas.Visa)) for _, v := range visas.Visa { if checkVisaType(v, "ControlledAccessGrants") { verifiedVisa, valid := validateVisa(v) if valid { datasets = getDatasets(verifiedVisa, datasets) } } } log.Debugf("matched datasets: %s", datasets) return datasets }
GetPermissions parses visas and finds matching dataset names from the database, returning a list of matches
View Source
var GetToken = func(headers http.Header) (string, int, error) { log.Debug("parsing access token from header") header := headers.Get("X-Amz-Security-Token") if len(header) != 0 { return header, 0, nil } header = headers.Get("Authorization") if len(header) == 0 { log.Debug("authorization check failed") return "", 401, errors.New("access token must be provided") } headerParts := strings.Split(header, " ") if headerParts[0] != "Bearer" { log.Debug("authorization check failed") return "", 400, errors.New("authorization scheme must be bearer") } // Check that header contains a token string var token string if len(headerParts) == 2 { token = headerParts[1] } else { log.Debug("authorization check failed") return "", 400, errors.New("token string is missing from authorization header") } log.Debug("access token found") return token, 0, nil }
GetToken parses the token string from a `http.Header`. The token string can come with either the S3 "X-Amz-Security-Token" header or the "Authorization" header. The "X-Amz-Security-Token" header is checked first, since it requires less formatting.
View Source
var GetVisas = func(o OIDCDetails, token string) (*Visas, error) { log.Debugf("requesting visas from %s", o.Userinfo) headers := map[string]string{} headers["Authorization"] = "Bearer " + token response, err := request.MakeRequest("GET", o.Userinfo, headers, nil) if err != nil { log.Errorf("request failed, %s", err) return nil, err } // Parse response var v Visas err = json.NewDecoder(response.Body).Decode(&v) if err != nil { log.Errorf("failed to parse JSON response, %s", err) return nil, err } log.Debug("visas received") return &v, nil }
GetVisas requests the list of visas from userinfo endpoint
Functions ¶
Types ¶
type OIDCDetails ¶
OIDCDetails is used to draw the response bytes to a struct
var Details OIDCDetails
Details stores an OIDCDetails struct
func GetOIDCDetails ¶
func GetOIDCDetails(url string) (OIDCDetails, error)
GetOIDCDetails requests OIDC configuration information
Click to show internal directories.
Click to hide internal directories.