grafana/pkg/services/authn/clients/identity.go
linoman 51da96d94e
Auth: Add IsClientEnabled and IsEnabled for the authn.Service and authn.Client interfaces (#86034)
* Add `Service. IsClientEnabled` and `Client.IsEnabled` functions

* Implement `IsEnabled` function for authn clients

* Implement `IsClientEnabled` function for authn services
2024-04-15 10:54:50 +02:00

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
}