2022-01-14 18:49:22 +00:00
|
|
|
// Copyright 2021-2022 the Pinniped contributors. All Rights Reserved.
|
2021-04-07 23:12:13 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-04-10 01:49:43 +00:00
|
|
|
// Package authenticators contains authenticator interfaces.
|
|
|
|
package authenticators
|
2021-04-07 23:12:13 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-11-03 17:33:22 +00:00
|
|
|
"k8s.io/apiserver/pkg/authentication/user"
|
2021-04-07 23:12:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// This interface is similar to the k8s token authenticator, but works with username/passwords instead
|
|
|
|
// of a single token string.
|
|
|
|
//
|
2021-04-09 00:28:01 +00:00
|
|
|
// The return values should be as follows.
|
|
|
|
// 1. For a successful authentication:
|
|
|
|
// - A response which includes the username, uid, and groups in the userInfo. The username and uid must not be blank.
|
|
|
|
// - true
|
|
|
|
// - nil error
|
|
|
|
// 2. For an unsuccessful authentication, e.g. bad username or password:
|
|
|
|
// - nil response
|
|
|
|
// - false
|
|
|
|
// - nil error
|
|
|
|
// 3. For an unexpected error, e.g. a network problem:
|
|
|
|
// - nil response
|
|
|
|
// - false
|
|
|
|
// - an error
|
|
|
|
// Other combinations of return values must be avoided.
|
|
|
|
//
|
2021-04-07 23:12:13 +00:00
|
|
|
// See k8s.io/apiserver/pkg/authentication/authenticator/interfaces.go for the token authenticator
|
|
|
|
// interface, as well as the Response type.
|
|
|
|
type UserAuthenticator interface {
|
2022-06-22 17:58:08 +00:00
|
|
|
AuthenticateUser(ctx context.Context, username, password string, grantedScopes []string) (*Response, bool, error)
|
2021-11-03 17:33:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Response struct {
|
2021-12-09 22:02:40 +00:00
|
|
|
User user.Info
|
|
|
|
DN string
|
|
|
|
ExtraRefreshAttributes map[string]string
|
2021-04-07 23:12:13 +00:00
|
|
|
}
|