mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-16 10:45:12 +00:00
chore: Service Account Naming Consistency (#11557)
# Which Problems Are Solved Inconsistent naming of service account, found in the following variations: - Machine User - machine user - Service User - Machine Account - Technical Account - User: Type Machine # How the Problems Are Solved Attentive search and replace. Localizations have been translated using Copilot # Additional Changes Some unused methods have been removed from the Go code. # Additional Context - Closes #11285
This commit is contained in:
@@ -151,7 +151,7 @@ func projectIDAndCheckOriginForClientID(ctx context.Context, clientID string, t
|
||||
projectID, origins, err := t.ProjectIDAndOriginsByClientID(ctx, clientID)
|
||||
logging.WithFields("clientID", clientID).OnError(err).Debug("could not check projectID and origin of clientID (might be service account)")
|
||||
|
||||
// We used to check origins for every token, but service users shouldn't be used publicly (native app / SPA).
|
||||
// We used to check origins for every token, but service accounts shouldn't be used publicly (native app / SPA).
|
||||
// Therefore, mostly won't send an origin and aren't able to configure them anyway.
|
||||
// For the current time we will only check origins for tokens issued to users through apps (code / implicit flow).
|
||||
if projectID == "" {
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestServer_ListAdministrators(t *testing.T) {
|
||||
organizationAdmin2 := createOrganizationAdministrator(iamOwnerCtx, instanceQuery, organizationResp.GetOrganizationId(), organizationName, t)
|
||||
organizationAdmin3 := createOrganizationAdministrator(iamOwnerCtx, instanceQuery, organizationResp.GetOrganizationId(), organizationName, t)
|
||||
|
||||
// Additionally, a machine user as a project grant owner to test permissions
|
||||
// Additionally, a service account as a project grant owner to test permissions
|
||||
userOrganizationResp := instanceQuery.CreateMachineUser(iamOwnerCtx)
|
||||
instanceQuery.CreateOrgMembership(t, iamOwnerCtx, organizationResp.GetOrganizationId(), userOrganizationResp.GetUserId())
|
||||
patOrganizationResp := instanceQuery.CreatePersonalAccessToken(iamOwnerCtx, userOrganizationResp.GetUserId())
|
||||
@@ -42,7 +42,7 @@ func TestServer_ListAdministrators(t *testing.T) {
|
||||
projectAdministrator2 := createProjectAdministrator(iamOwnerCtx, instanceQuery, t, organizationResp.GetOrganizationId(), projectResp.GetId(), projectName)
|
||||
projectAdministrator3 := createProjectAdministrator(iamOwnerCtx, instanceQuery, t, organizationResp.GetOrganizationId(), projectResp.GetId(), projectName)
|
||||
|
||||
// Additionally, a machine user as a project owner to test permissions
|
||||
// Additionally, a service account as a project owner to test permissions
|
||||
userProjectResp := instanceQuery.CreateMachineUser(iamOwnerCtx)
|
||||
instanceQuery.CreateProjectMembership(t, iamOwnerCtx, projectResp.GetId(), userProjectResp.GetUserId())
|
||||
patProjectResp := instanceQuery.CreatePersonalAccessToken(iamOwnerCtx, userProjectResp.GetUserId())
|
||||
@@ -56,7 +56,7 @@ func TestServer_ListAdministrators(t *testing.T) {
|
||||
projectGrantAdministrator2 := createProjectGrantAdministrator(iamOwnerCtx, instanceQuery, t, organizationResp.GetOrganizationId(), projectResp.GetId(), projectName, grantedOrganizationResp.GetOrganizationId())
|
||||
projectGrantAdministrator3 := createProjectGrantAdministrator(iamOwnerCtx, instanceQuery, t, organizationResp.GetOrganizationId(), projectResp.GetId(), projectName, grantedOrganizationResp.GetOrganizationId())
|
||||
|
||||
// Additionally, a machine user as a project grant owner to test permissions
|
||||
// Additionally, a service account as a project grant owner to test permissions
|
||||
userProjectGrantResp := instanceQuery.CreateMachineUser(iamOwnerCtx)
|
||||
instanceQuery.CreateProjectGrantMembership(t, iamOwnerCtx, projectResp.GetId(), grantedOrganizationResp.GetOrganizationId(), userProjectGrantResp.GetUserId())
|
||||
patProjectGrantResp := instanceQuery.CreatePersonalAccessToken(iamOwnerCtx, userProjectGrantResp.GetUserId())
|
||||
@@ -845,7 +845,7 @@ func TestServer_ListAdministrators_PermissionV2(t *testing.T) {
|
||||
organizationAdmin2 := createOrganizationAdministrator(iamOwnerCtx, instancePermissionV2, organizationResp.GetOrganizationId(), organizationName, t)
|
||||
organizationAdmin3 := createOrganizationAdministrator(iamOwnerCtx, instancePermissionV2, organizationResp.GetOrganizationId(), organizationName, t)
|
||||
|
||||
// Additionally, a machine user as a project grant owner to test permissions
|
||||
// Additionally, a service account as a project grant owner to test permissions
|
||||
userOrganizationResp := instancePermissionV2.CreateMachineUser(iamOwnerCtx)
|
||||
instancePermissionV2.CreateOrgMembership(t, iamOwnerCtx, organizationResp.GetOrganizationId(), userOrganizationResp.GetUserId())
|
||||
patOrganizationResp := instancePermissionV2.CreatePersonalAccessToken(iamOwnerCtx, userOrganizationResp.GetUserId())
|
||||
@@ -858,7 +858,7 @@ func TestServer_ListAdministrators_PermissionV2(t *testing.T) {
|
||||
projectAdministrator2 := createProjectAdministrator(iamOwnerCtx, instancePermissionV2, t, organizationResp.GetOrganizationId(), projectResp.GetId(), projectName)
|
||||
projectAdministrator3 := createProjectAdministrator(iamOwnerCtx, instancePermissionV2, t, organizationResp.GetOrganizationId(), projectResp.GetId(), projectName)
|
||||
|
||||
// Additionally, a machine user as a project owner to test permissions
|
||||
// Additionally, a service account as a project owner to test permissions
|
||||
userProjectResp := instancePermissionV2.CreateMachineUser(iamOwnerCtx)
|
||||
instancePermissionV2.CreateProjectMembership(t, iamOwnerCtx, projectResp.GetId(), userProjectResp.GetUserId())
|
||||
patProjectResp := instancePermissionV2.CreatePersonalAccessToken(iamOwnerCtx, userProjectResp.GetUserId())
|
||||
@@ -872,7 +872,7 @@ func TestServer_ListAdministrators_PermissionV2(t *testing.T) {
|
||||
projectGrantAdministrator2 := createProjectGrantAdministrator(iamOwnerCtx, instancePermissionV2, t, organizationResp.GetOrganizationId(), projectResp.GetId(), projectName, grantedOrganizationResp.GetOrganizationId())
|
||||
projectGrantAdministrator3 := createProjectGrantAdministrator(iamOwnerCtx, instancePermissionV2, t, organizationResp.GetOrganizationId(), projectResp.GetId(), projectName, grantedOrganizationResp.GetOrganizationId())
|
||||
|
||||
// Additionally, a machine user as a project grant owner to test permissions
|
||||
// Additionally, a service account as a project grant owner to test permissions
|
||||
userProjectGrantResp := instancePermissionV2.CreateMachineUser(iamOwnerCtx)
|
||||
instancePermissionV2.CreateProjectGrantMembership(t, iamOwnerCtx, projectResp.GetId(), grantedOrganizationResp.GetOrganizationId(), userProjectGrantResp.GetUserId())
|
||||
patProjectGrantResp := instancePermissionV2.CreatePersonalAccessToken(iamOwnerCtx, userProjectGrantResp.GetUserId())
|
||||
|
||||
@@ -221,7 +221,7 @@ func TestServer_CreateProject_Permission(t *testing.T) {
|
||||
}
|
||||
|
||||
func getOrgProjectCreatorToken(t *testing.T, ctx context.Context, orgId1, orgId2 string) string {
|
||||
// create a machine user in Org 1
|
||||
// create a service account in Org 1
|
||||
userResp := instance.CreateUserTypeMachine(ctx, orgId1)
|
||||
|
||||
// assign ORG_PROJECT_CREATOR role in Org 2
|
||||
@@ -970,7 +970,6 @@ func TestServer_ActivateProject(t *testing.T) {
|
||||
name: "not existing",
|
||||
prepare: func(request *project.ActivateProjectRequest) {
|
||||
request.ProjectId = "notexisting"
|
||||
return
|
||||
},
|
||||
args: args{
|
||||
ctx: iamOwnerCtx,
|
||||
|
||||
@@ -200,7 +200,7 @@ func TestServer_CreateProject_Permission(t *testing.T) {
|
||||
}
|
||||
|
||||
func getOrgProjectCreatorToken(t *testing.T, ctx context.Context, orgId1, orgId2 string) string {
|
||||
// create a machine user in Org 1
|
||||
// create a service account in Org 1
|
||||
userResp := instance.CreateUserTypeMachine(ctx, orgId1)
|
||||
|
||||
// assign ORG_PROJECT_CREATOR role in Org 2
|
||||
@@ -953,7 +953,6 @@ func TestServer_ActivateProject(t *testing.T) {
|
||||
name: "not existing",
|
||||
prepare: func(request *project.ActivateProjectRequest) {
|
||||
request.Id = "notexisting"
|
||||
return
|
||||
},
|
||||
args: args{
|
||||
ctx: iamOwnerCtx,
|
||||
|
||||
@@ -824,7 +824,7 @@ func Test_UsersToPb(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "slice with one machine user",
|
||||
name: "slice with one service account",
|
||||
args: args{
|
||||
users: []*query.User{
|
||||
{
|
||||
|
||||
@@ -398,7 +398,7 @@ func TestServer_ListUsers(t *testing.T) {
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "list user by id, no permission machine user",
|
||||
name: "list user by id, no permission service account",
|
||||
args: args{
|
||||
InstancePermissionV2.WithAuthorizationToken(OrgCTX, integration.UserTypeNoPermission),
|
||||
&user.ListUsersRequest{},
|
||||
|
||||
@@ -3358,7 +3358,7 @@ func TestServer_CreateUser(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "machine user",
|
||||
name: "service account",
|
||||
testCase: func(runId string) testCase {
|
||||
username := fmt.Sprintf("donald.duck+%s", runId)
|
||||
return testCase{
|
||||
@@ -3577,7 +3577,7 @@ func TestServer_CreateUser_And_Compare(t *testing.T) {
|
||||
}
|
||||
},
|
||||
}, {
|
||||
name: "machine username given",
|
||||
name: "service accountname given",
|
||||
testCase: func(runId string) testCase {
|
||||
username := fmt.Sprintf("donald.duck+%s", runId)
|
||||
return testCase{
|
||||
@@ -3599,7 +3599,7 @@ func TestServer_CreateUser_And_Compare(t *testing.T) {
|
||||
}
|
||||
},
|
||||
}, {
|
||||
name: "machine username default to generated id",
|
||||
name: "service accountname default to generated id",
|
||||
testCase: func(runId string) testCase {
|
||||
return testCase{
|
||||
args: args{
|
||||
@@ -3619,7 +3619,7 @@ func TestServer_CreateUser_And_Compare(t *testing.T) {
|
||||
}
|
||||
},
|
||||
}, {
|
||||
name: "machine username default to given id",
|
||||
name: "service accountname default to given id",
|
||||
testCase: func(runId string) testCase {
|
||||
return testCase{
|
||||
args: args{
|
||||
@@ -3795,7 +3795,7 @@ func TestServer_CreateUser_Permission(t *testing.T) {
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "machine user, error",
|
||||
name: "service account, error",
|
||||
args: args{
|
||||
UserCTX,
|
||||
&user.CreateUserRequest{
|
||||
@@ -4150,7 +4150,7 @@ func TestServer_UpdateUserTypeMachine(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "update machine user with human fields, error",
|
||||
name: "update service account with human fields, error",
|
||||
testCase: func(runId, userId string) testCase {
|
||||
return testCase{
|
||||
args: args{
|
||||
@@ -4280,7 +4280,7 @@ func TestServer_UpdateUser_And_Compare(t *testing.T) {
|
||||
}
|
||||
},
|
||||
}, {
|
||||
name: "machine username",
|
||||
name: "service accountname",
|
||||
testCase: func(runId string) testCase {
|
||||
username := fmt.Sprintf("donald.duck+%s", runId)
|
||||
return testCase{
|
||||
@@ -4493,7 +4493,7 @@ func TestServer_UpdateUser_Permission(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "machine user, error",
|
||||
name: "service account, error",
|
||||
testCase: func() testCase {
|
||||
return testCase{
|
||||
args: args{
|
||||
|
||||
@@ -393,7 +393,7 @@ func TestServer_ListUsers(t *testing.T) {
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "list user by id, no permission machine user",
|
||||
name: "list user by id, no permission service account",
|
||||
args: args{
|
||||
UserCTX,
|
||||
&user_v2beta.ListUsersRequest{},
|
||||
|
||||
@@ -51,12 +51,12 @@ type clientCredentialsClient struct {
|
||||
}
|
||||
|
||||
// AccessTokenType returns the AccessTokenType for the token to be created because of the client credentials request
|
||||
// machine users currently only have opaque tokens ([op.AccessTokenTypeBearer])
|
||||
// service accounts currently only have opaque tokens ([op.AccessTokenTypeBearer])
|
||||
func (c *clientCredentialsClient) AccessTokenType() op.AccessTokenType {
|
||||
return accessTokenTypeToOIDC(c.tokenType)
|
||||
}
|
||||
|
||||
// GetID returns the client_id (username of the machine user) for the token to be created because of the client credentials request
|
||||
// GetID returns the client_id (username of the service account) for the token to be created because of the client credentials request
|
||||
func (c *clientCredentialsClient) GetID() string {
|
||||
return c.clientID
|
||||
}
|
||||
@@ -71,12 +71,12 @@ func (c *clientCredentialsClient) PostLogoutRedirectURIs() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ApplicationType returns [op.ApplicationTypeWeb] as the machine users is a confidential client
|
||||
// ApplicationType returns [op.ApplicationTypeWeb] as the service accounts is a confidential client
|
||||
func (c *clientCredentialsClient) ApplicationType() op.ApplicationType {
|
||||
return op.ApplicationTypeWeb
|
||||
}
|
||||
|
||||
// AuthMethod returns the allowed auth method type for machine user.
|
||||
// AuthMethod returns the allowed auth method type for service account.
|
||||
// It returns Basic Auth
|
||||
func (c *clientCredentialsClient) AuthMethod() oidc.AuthMethod {
|
||||
return oidc.AuthMethodBasic
|
||||
@@ -87,7 +87,7 @@ func (c *clientCredentialsClient) ResponseTypes() []oidc.ResponseType {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GrantTypes returns the grant types supported by the machine users, which is currently only client credentials ([oidc.GrantTypeClientCredentials])
|
||||
// GrantTypes returns the grant types supported by the service accounts, which is currently only client credentials ([oidc.GrantTypeClientCredentials])
|
||||
func (c *clientCredentialsClient) GrantTypes() []oidc.GrantType {
|
||||
return []oidc.GrantType{
|
||||
oidc.GrantTypeClientCredentials,
|
||||
@@ -132,7 +132,7 @@ func (c *clientCredentialsClient) IDTokenUserinfoClaimsAssertion() bool {
|
||||
|
||||
// ClockSkew enable handling clock skew of the token validation. The duration (0-5s) will be added to exp claim and subtracted from iats,
|
||||
// auth_time and nbf of the token to be created because of the client credentials request.
|
||||
// It returns 0 as clock skew is not implemented on machine users.
|
||||
// It returns 0 as clock skew is not implemented on service accounts.
|
||||
func (c *clientCredentialsClient) ClockSkew() time.Duration {
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestServer_ClientCredentialsExchange(t *testing.T) {
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "machine user without secret error",
|
||||
name: "service account without secret error",
|
||||
clientID: func() string {
|
||||
name := integration.Username()
|
||||
_, err := Instance.Client.Mgmt.AddMachineUser(CTX, &management.AddMachineUserRequest{
|
||||
@@ -75,7 +75,7 @@ func TestServer_ClientCredentialsExchange(t *testing.T) {
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "inactive machine user error",
|
||||
name: "inactive service account error",
|
||||
clientID: clientIDInactive,
|
||||
clientSecret: clientSecretInactive,
|
||||
scope: []string{oidc.ScopeOpenID},
|
||||
|
||||
@@ -35,7 +35,7 @@ func (s *Server) ClientCredentialsExchange(ctx context.Context, r *op.ClientRequ
|
||||
client.userID,
|
||||
client.resourceOwner,
|
||||
client.clientID,
|
||||
"", // backChannelLogoutURI not needed for service user session
|
||||
"", // backChannelLogoutURI not needed for service account session
|
||||
scope,
|
||||
domain.AddAudScopeToAudience(ctx, nil, r.Data.Scope),
|
||||
[]domain.UserAuthMethodType{domain.UserAuthMethodTypePassword},
|
||||
|
||||
@@ -45,7 +45,7 @@ func (s *Server) JWTProfile(ctx context.Context, r *op.Request[oidc.JWTProfileGr
|
||||
client.userID,
|
||||
client.resourceOwner,
|
||||
client.clientID,
|
||||
"", // backChannelLogoutURI not needed for service user session
|
||||
"", // backChannelLogoutURI not needed for service account session
|
||||
scope,
|
||||
domain.AddAudScopeToAudience(ctx, nil, r.Data.Scope),
|
||||
[]domain.UserAuthMethodType{domain.UserAuthMethodTypePrivateKey},
|
||||
|
||||
@@ -412,12 +412,11 @@ func TestCreateUser_scopedExternalID(t *testing.T) {
|
||||
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(ctx, time.Minute)
|
||||
require.EventuallyWithT(t, func(tt *assert.CollectT) {
|
||||
// unscoped externalID should not exist
|
||||
unscoped, err := Instance.Client.Mgmt.GetUserMetadata(ctx, &management.GetUserMetadataRequest{
|
||||
_, err := Instance.Client.Mgmt.GetUserMetadata(ctx, &management.GetUserMetadataRequest{
|
||||
Id: createdUser.ID,
|
||||
Key: "urn:zitadel:scim:externalId",
|
||||
})
|
||||
integration.AssertGrpcStatus(tt, codes.NotFound, err)
|
||||
unscoped = unscoped
|
||||
|
||||
// scoped externalID should exist
|
||||
md, err := Instance.Client.Mgmt.GetUserMetadata(ctx, &management.GetUserMetadataRequest{
|
||||
@@ -478,12 +477,12 @@ func TestCreateUser_ignorePasswordOnCreate(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
// create a machine user
|
||||
// create a service account
|
||||
callingUserId, callingUserPat, err := Instance.CreateMachineUserPATWithMembership(CTX, "ORG_OWNER")
|
||||
require.NoError(t, err)
|
||||
ctx := integration.WithAuthorizationToken(CTX, callingUserPat)
|
||||
|
||||
// set urn:zitadel:scim:ignorePasswordOnCreate metadata for the machine user
|
||||
// set urn:zitadel:scim:ignorePasswordOnCreate metadata for the service account
|
||||
setAndEnsureMetadata(t, callingUserId, "urn:zitadel:scim:ignorePasswordOnCreate", tt.ignorePassword)
|
||||
|
||||
// create a user with an invalid password
|
||||
|
||||
@@ -365,7 +365,7 @@ var totalCountOfHumanUsers = 13
|
||||
prepare: func(t require.TestingT) *scim.ListRequest {
|
||||
resp := createHumanUser(t, CTX, Instance.DefaultOrg.Id, 102)
|
||||
|
||||
// set provisioning domain of service user
|
||||
// set provisioning domain of service account
|
||||
setProvisioningDomain(t, Instance.Users.Get(integration.UserTypeOrgOwner).ID, "fooBar")
|
||||
|
||||
// set externalID for provisioning domain
|
||||
@@ -379,7 +379,7 @@ var totalCountOfHumanUsers = 13
|
||||
assert.Equal(t, resp.Resources[0].ExternalID, "100-scopedExternalId")
|
||||
},
|
||||
cleanup: func(t require.TestingT) {
|
||||
// delete provisioning domain of service user
|
||||
// delete provisioning domain of service account
|
||||
removeProvisioningDomain(t, Instance.Users.Get(integration.UserTypeOrgOwner).ID)
|
||||
},
|
||||
},
|
||||
|
||||
@@ -344,7 +344,7 @@ func TestReplaceUser_scopedExternalID(t *testing.T) {
|
||||
callingUserId, callingUserPat, err := Instance.CreateMachineUserPATWithMembership(CTX, "ORG_OWNER")
|
||||
require.NoError(t, err)
|
||||
ctx := integration.WithAuthorizationToken(CTX, callingUserPat)
|
||||
// set provisioning domain of service user
|
||||
// set provisioning domain of service account
|
||||
setProvisioningDomain(t, callingUserId, "fooBazz")
|
||||
|
||||
// replace the user with provisioning domain set
|
||||
|
||||
@@ -35,7 +35,7 @@ func initScimContext(ctx context.Context, q *query.Queries) (context.Context, er
|
||||
|
||||
userID := authz.GetCtxData(ctx).UserID
|
||||
|
||||
// get the provisioningDomain and ignorePasswordOnCreate metadata keys associated with the service user
|
||||
// get the provisioningDomain and ignorePasswordOnCreate metadata keys associated with the service account
|
||||
metadataKeys := []smetadata.Key{
|
||||
smetadata.KeyProvisioningDomain,
|
||||
smetadata.KeyIgnorePasswordOnCreate,
|
||||
|
||||
Reference in New Issue
Block a user