drone/internal/auth/authn/authenticator.go
Enver Bisevac f03528e862 [MAINT] initial config for ci linter (#17)
* initial config for ci linter

* more linter work

* linter errors fix

* linter errors fix

* linter conf minor changes
2022-09-19 18:13:18 +02:00

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)
}