mirror of https://github.com/grafana/grafana
Authn: Add function to resolve identity from org and namespace id (#84555)
* Add function to get the namespaced id * Add function to resolve an identity through authn.Service from org and namespace id * Switch to resolve identity for re-authenticate in another orgpull/83163/head^2
parent
ced09883d3
commit
d4e802dd47
@ -0,0 +1,33 @@ |
|||||||
|
package clients |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/services/authn" |
||||||
|
) |
||||||
|
|
||||||
|
var _ authn.Client = (*IdentityClient)(nil) |
||||||
|
|
||||||
|
func ProvideIdentity(namespaceID string) *IdentityClient { |
||||||
|
return &IdentityClient{namespaceID} |
||||||
|
} |
||||||
|
|
||||||
|
type IdentityClient struct { |
||||||
|
namespaceID string |
||||||
|
} |
||||||
|
|
||||||
|
func (i *IdentityClient) Name() string { |
||||||
|
return "identity" |
||||||
|
} |
||||||
|
|
||||||
|
// Authenticate implements authn.Client.
|
||||||
|
func (i *IdentityClient) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) { |
||||||
|
return &authn.Identity{ |
||||||
|
OrgID: r.OrgID, |
||||||
|
ID: i.namespaceID, |
||||||
|
ClientParams: authn.ClientParams{ |
||||||
|
FetchSyncedUser: true, |
||||||
|
SyncPermissions: true, |
||||||
|
}, |
||||||
|
}, nil |
||||||
|
} |
||||||
Loading…
Reference in new issue