Skip to content

Instantly share code, notes, and snippets.

@Riduidel
Created May 26, 2017 14:29
Show Gist options
  • Select an option

  • Save Riduidel/6b03ac870ae5c1d28102da10782ab9f7 to your computer and use it in GitHub Desktop.

Select an option

Save Riduidel/6b03ac870ae5c1d28102da10782ab9f7 to your computer and use it in GitHub Desktop.
func (h *handler) checkAuth(context *db.DatabaseContext) error {
h.user = nil
if context == nil {
return nil
}
defer checkAuthRollingMean.AddSince(time.Now())
var err error
// If oidc enabled, check for bearer ID token
if context.Options.OIDCOptions != nil {
if token := h.getBearerToken(); token != "" {
h.user, _, err = context.Authenticator().AuthenticateUntrustedJWT(token, context.OIDCProviders, h.getOIDCCallbackURL)
if h.user == nil || err != nil {
return base.HTTPErrorf(http.StatusUnauthorized, "Invalid login")
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment