Auth: Add OrgRole to ID token (#100383)

* Changes for Users and ServiceAccounts

* Align tests
This commit is contained in:
Misi
2025-02-12 05:51:29 -08:00
committed by GitHub
parent a5c8b5ed83
commit ee0a1391df
19 changed files with 202 additions and 66 deletions
+4
View File
@@ -109,6 +109,10 @@ func (s *Service) SignIdentity(ctx context.Context, id identity.Requester) (stri
idClaims.Rest.DisplayName = id.GetName()
}
if id.GetOrgRole().IsValid() {
idClaims.Rest.Role = string(id.GetOrgRole())
}
token, err := s.signer.SignIDToken(ctx, idClaims)
if err != nil {
s.metrics.failedTokenSigningCounter.Inc()
+1 -1
View File
@@ -34,7 +34,7 @@ func Test_ProvideService(t *testing.T) {
}
func TestService_SignIdentity(t *testing.T) {
signer := &idtest.MockSigner{
signer := &idtest.FakeSigner{
SignIDTokenFn: func(_ context.Context, claims *auth.IDClaims) (string, error) {
key := []byte("key")
s, err := jose.NewSigner(jose.SigningKey{Algorithm: jose.HS256, Key: key}, nil)