mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 04:04:00 -06:00
51da96d94e
* Add `Service. IsClientEnabled` and `Client.IsEnabled` functions * Implement `IsEnabled` function for authn clients * Implement `IsClientEnabled` function for authn services
30 lines
548 B
Go
30 lines
548 B
Go
package clients
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/services/authn"
|
|
)
|
|
|
|
var _ authn.Client = (*IdentityClient)(nil)
|
|
|
|
func ProvideIdentity(identity *authn.Identity) *IdentityClient {
|
|
return &IdentityClient{identity}
|
|
}
|
|
|
|
type IdentityClient struct {
|
|
identity *authn.Identity
|
|
}
|
|
|
|
func (i *IdentityClient) Name() string {
|
|
return "identity"
|
|
}
|
|
|
|
func (i *IdentityClient) IsEnabled() bool {
|
|
return true
|
|
}
|
|
|
|
func (i *IdentityClient) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) {
|
|
return i.identity, nil
|
|
}
|