IAM: Protect external service accounts frontend list page (#77834)
* Add `isExternal` property to frontend model * Remove enabled and token buttons for external SA * Replace trash icon for lock icon for external SA * Block the role picker for external SA * Filter SA list using the external filter * Add only external filter at backend --------- Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
This commit is contained in:
co-authored by
Gabriel MABILLE
parent
d4322f6e5a
commit
5bc4f56c79
@@ -41,7 +41,7 @@ func ProvideServiceAccountsProxy(
|
||||
isProxyEnabled: features.IsEnabled(featuremgmt.FlagExternalServiceAccounts) || features.IsEnabled(featuremgmt.FlagExternalServiceAuth),
|
||||
}
|
||||
|
||||
serviceaccountsAPI := api.NewServiceAccountsAPI(cfg, s, ac, accesscontrolService, routeRegister, permissionService)
|
||||
serviceaccountsAPI := api.NewServiceAccountsAPI(cfg, s, ac, accesscontrolService, routeRegister, permissionService, features)
|
||||
serviceaccountsAPI.RegisterAPIEndpoints()
|
||||
|
||||
return s, nil
|
||||
@@ -138,7 +138,7 @@ func (s *ServiceAccountsProxy) RetrieveServiceAccount(ctx context.Context, orgID
|
||||
}
|
||||
|
||||
if s.isProxyEnabled {
|
||||
sa.IsManaged = isExternalServiceAccount(sa.Login)
|
||||
sa.IsExternal = isExternalServiceAccount(sa.Login)
|
||||
}
|
||||
|
||||
return sa, nil
|
||||
@@ -175,7 +175,7 @@ func (s *ServiceAccountsProxy) SearchOrgServiceAccounts(ctx context.Context, que
|
||||
|
||||
if s.isProxyEnabled {
|
||||
for i := range sa.ServiceAccounts {
|
||||
sa.ServiceAccounts[i].IsManaged = isExternalServiceAccount(sa.ServiceAccounts[i].Login)
|
||||
sa.ServiceAccounts[i].IsExternal = isExternalServiceAccount(sa.ServiceAccounts[i].Login)
|
||||
}
|
||||
}
|
||||
return sa, nil
|
||||
|
||||
@@ -146,7 +146,7 @@ func TestProvideServiceAccount_crudServiceAccount(t *testing.T) {
|
||||
serviceMock.ExpectedServiceAccountProfile = tc.expectedServiceAccount
|
||||
sa, err := svc.RetrieveServiceAccount(context.Background(), testOrgId, testServiceAccountId)
|
||||
assert.NoError(t, err, tc.description)
|
||||
assert.Equal(t, tc.expectedIsExternal, sa.IsManaged, tc.description)
|
||||
assert.Equal(t, tc.expectedIsExternal, sa.IsExternal, tc.description)
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -164,8 +164,8 @@ func TestProvideServiceAccount_crudServiceAccount(t *testing.T) {
|
||||
res, err := svc.SearchOrgServiceAccounts(context.Background(), &serviceaccounts.SearchOrgServiceAccountsQuery{OrgID: 1})
|
||||
require.Len(t, res.ServiceAccounts, 2)
|
||||
require.NoError(t, err)
|
||||
require.False(t, res.ServiceAccounts[0].IsManaged)
|
||||
require.True(t, res.ServiceAccounts[1].IsManaged)
|
||||
require.False(t, res.ServiceAccounts[0].IsExternal)
|
||||
require.True(t, res.ServiceAccounts[1].IsExternal)
|
||||
})
|
||||
|
||||
t.Run("should update service account", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user