2024-03-15 09:08:15 -05:00
|
|
|
package clients
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/services/authn"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ authn.Client = (*IdentityClient)(nil)
|
|
|
|
|
2024-04-12 04:38:20 -05:00
|
|
|
func ProvideIdentity(identity *authn.Identity) *IdentityClient {
|
|
|
|
return &IdentityClient{identity}
|
2024-03-15 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type IdentityClient struct {
|
2024-04-12 04:38:20 -05:00
|
|
|
identity *authn.Identity
|
2024-03-15 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i *IdentityClient) Name() string {
|
|
|
|
return "identity"
|
|
|
|
}
|
|
|
|
|
2024-04-15 03:54:50 -05:00
|
|
|
func (i *IdentityClient) IsEnabled() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-03-15 09:08:15 -05:00
|
|
|
func (i *IdentityClient) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) {
|
2024-04-12 04:38:20 -05:00
|
|
|
return i.identity, nil
|
2024-03-15 09:08:15 -05:00
|
|
|
}
|