...

Package authgroup

import "github.com/go-kivik/kivik/v4/x/kivikd/authdb/authgroup"
Overview
Index

Overview ▾

Package authgroup groups two or more authentication backends together, trying one, then falling through to the others.

func New

func New(userStores ...authdb.UserStore) authdb.UserStore

New initializes a group of auth handlers. Each one is tried in turn, in the order passed to New.

type AuthGroup

AuthGroup is a group of auth handlers, to be tried in turn.

type AuthGroup []authdb.UserStore

func (AuthGroup) UserCtx

func (g AuthGroup) UserCtx(ctx context.Context, username string) (*authdb.UserContext, error)

UserCtx loops through each of the auth handlers, in the order passed to New until the context is cancelled, in which case the context's error is returned. The first one to not return an error returns. If all of the handlers return a Not Found error, Not Found is returned. If any other errors are returned, the first is returned to the caller.

func (AuthGroup) Validate

func (g AuthGroup) Validate(ctx context.Context, username, password string) (*authdb.UserContext, error)

Validate loops through each of the auth handlers, in the order passed to New, until the context is cancelled, in which case the context's error is returned. The first validation success returns. Errors are discarded unless all auth handlers fail to validate the user, in which case only the first error received will be returned.