Skip to content

Commit 639f5ab

Browse files
committed
feat: add TOKEN_AUDIENCE configuration
1 parent fd859b5 commit 639f5ab

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

charts/kerbernetes/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ spec:
2424
value: "{{ .Values.httpPort }}"
2525
- name: LDAP_ENABLED
2626
value: "{{ .Values.ldap.enabled }}"
27+
- name: TOKEN_AUDIENCE
28+
value: "{{ .Values.token.audience }}"
2729
{{- if and .Values.ldap.enabled .Values.secrets.ldapSecret }}
2830
- name: LDAP_BASE_DN
2931
value: "{{ .Values.ldap.baseDN }}"

charts/kerbernetes/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ image:
99

1010
httpPort: 3000
1111

12+
token:
13+
audience: "https://kubernetes.default.svc.cluster.local"
14+
1215
ldap:
1316
enabled: false
1417
url: "ldap://ldap.example.com"

internal/services/auth/auth.service.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ func (s *authService) AuthAccount(
9292
}, nil
9393
}
9494

95-
func (s *authService) ldapReconcilate(ctx context.Context, username string, sa *corev1.ServiceAccount) error {
95+
func (s *authService) ldapReconcilate(
96+
ctx context.Context,
97+
username string,
98+
sa *corev1.ServiceAccount,
99+
) error {
96100
user, err := s.ldapSvc.GetUser(username)
97101
if err != nil {
98102
s.logger.Error("Failed to get user from LDAP", "username", username, "error", err)

internal/services/env/env.service.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ type Env struct {
1616
KeytabPath string `mapstructure:"KEYTAB_PATH" default:"/etc/krb5.keytab" validate:"required"`
1717
Namespace string `mapstructure:"NAMESPACE" default:"default" validate:"required"`
1818

19-
TokenDuration int `mapstructure:"TOKEN_DURATION" default:"600" validate:"required"`
19+
TokenDuration int `mapstructure:"TOKEN_DURATION" default:"600" validate:"required"`
20+
TokenAudience string `mapstructure:"TOKEN_AUDIENCE" default:"https://kubernetes.default.svc.cluster.local"`
2021

2122
LDAPEnabled bool `mapstructure:"LDAP_ENABLED" default:"false"`
2223
LDAPURL string `mapstructure:"LDAP_URL"`

internal/services/k8s/serviceaccounts/serviceaccounts.service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (svc *serviceAccountsService) IssueToken(
135135
token, err := svc.clientset.CoreV1().ServiceAccounts(svc.namespace).
136136
CreateToken(ctx, username, &authv1.TokenRequest{
137137
Spec: authv1.TokenRequestSpec{
138-
Audiences: []string{"https://kubernetes.default.svc.cluster.local"},
138+
Audiences: []string{svc.env.TokenAudience},
139139
ExpirationSeconds: int64Ptr(int64(svc.env.TokenDuration)),
140140
},
141141
}, metav1.CreateOptions{})

0 commit comments

Comments
 (0)