Skip to content

Commit

Permalink
Set subject kind to ServiceAccount if username has service account pr…
Browse files Browse the repository at this point in the history
…efix

Signed-off-by: Rokibul Hasan <[email protected]>
  • Loading branch information
RokibulHasan7 committed Nov 12, 2024
1 parent 98d73e7 commit 200a8f4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/manager/controller/authentication/account_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,16 @@ func (r *AccountReconciler) createServiceAccount(ctx context.Context, acc *authe
}

func (r *AccountReconciler) createGatewayClusterRoleBindingForUser(ctx context.Context, acc *authenticationv1alpha1.Account) error {
// Determine subject kind based on whether the username contains the service account prefix
subKind := "User"
if strings.Contains(acc.Spec.Username, common.ServiceAccountPrefix) {
subKind = "ServiceAccount"
}

sub := []rbac.Subject{
{
APIGroup: "",
Kind: "User",
Kind: subKind,
Name: acc.Name,
Namespace: common.AddonAgentInstallNamespace,
},
Expand Down

0 comments on commit 200a8f4

Please sign in to comment.