mirror of
https://github.com/harness/drone.git
synced 2025-05-16 17:09:58 +08:00

* initial config for ci linter * more linter work * linter errors fix * linter errors fix * linter conf minor changes
31 lines
1016 B
Go
31 lines
1016 B
Go
// Copyright 2022 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package authn
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
|
|
"github.com/harness/gitness/types"
|
|
)
|
|
|
|
var (
|
|
// ErrNoAuthData that is returned if the authorizer doesn't find any data in the request that can be used for auth.
|
|
ErrNoAuthData = errors.New("the request doesn't contain any auth data that can be used by the Authorizer")
|
|
)
|
|
|
|
// Authenticator is abstraction of an entity that's responsible for authenticating users
|
|
// that are making calls via HTTP.
|
|
type Authenticator interface {
|
|
/*
|
|
* Tries to authenticate a user if credentials are available.
|
|
* Returns:
|
|
* (user, nil) - request contains auth data and user was verified
|
|
* (nil, ErrNoAuthData) - request doesn't contain any auth data
|
|
* (nil, err) - request contains auth data but verification failed
|
|
*/
|
|
Authenticate(r *http.Request) (*types.User, error)
|
|
}
|