The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/authz/token_auth.go

31 lines
741 B

package authz
import (
"context"
"github.com/grafana/authlib/authn"
)
func newGRPCTokenAuth(audience, namespace string, tc authn.TokenExchanger) *tokenAuth {
return &tokenAuth{audience, namespace, tc}
}
type tokenAuth struct {
audience string
namespace string
tokenClient authn.TokenExchanger
}
func (t *tokenAuth) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error) {
token, err := t.tokenClient.Exchange(ctx, authn.TokenExchangeRequest{
Namespace: t.namespace,
Audiences: []string{t.audience},
})
if err != nil {
return nil, err
}
return map[string]string{authn.DefaultAccessTokenMetadataKey: token.Token}, nil
}
func (t *tokenAuth) RequireTransportSecurity() bool { return false }