Skip to content

Commit

Permalink
Allow to configure OIDC subject name for eventshub sender (#749)
Browse files Browse the repository at this point in the history
* Allow to configure OIDC subject name for eventshub sender

* Update pkg/eventshub/options.go

Co-authored-by: Calum Murray <[email protected]>

---------

Co-authored-by: Calum Murray <[email protected]>
  • Loading branch information
creydr and Cali0707 authored Aug 12, 2024
1 parent dfa4862 commit fc8ca94
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/eventshub/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ func OIDCCorruptedSignature() EventsHubOption {
return compose(envOption(OIDCGenerateCorruptedSignatureTokenEnv, "true"), envOIDCEnabled())
}

// OIDCSubject sets the name of the OIDC subject to use by the sender. If this option is not set, it defaults to "oidc-<eventshub-name>"
func OIDCSubject(sub string) EventsHubOption {
return compose(envOption(OIDCSubjectEnv, sub), envOIDCEnabled())
}

// OIDCToken adds the given token used for OIDC authentication to the request.
func OIDCToken(jwt string) EventsHubOption {
return compose(envOption(OIDCTokenEnv, jwt), envOIDCEnabled())
Expand Down
3 changes: 3 additions & 0 deletions pkg/eventshub/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ func Install(name string, options ...EventsHubOption) feature.StepFn {
if isOIDCEnabled && !isReceiver {
// install oidc sa
oidcSAName := fmt.Sprintf("oidc-%s", name)
if envs[OIDCSubjectEnv] != "" {
oidcSAName = envs[OIDCSubjectEnv]
}
serviceaccount.Install(oidcSAName)(ctx, t)

// generate token
Expand Down
1 change: 1 addition & 0 deletions pkg/eventshub/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
OIDCEnabledEnv = "ENABLE_OIDC_AUTH"
OIDCGenerateExpiredTokenEnv = "OIDC_GENERATE_EXPIRED_TOKEN"
OIDCGenerateInvalidAudienceTokenEnv = "OIDC_GENERATE_INVALID_AUDIENCE_TOKEN"
OIDCSubjectEnv = "OIDC_SUBJECT"
OIDCGenerateCorruptedSignatureTokenEnv = "OIDC_GENERATE_CORRUPTED_SIG_TOKEN"
OIDCSinkAudienceEnv = "OIDC_SINK_AUDIENCE"
OIDCReceiverAudienceEnv = "OIDC_AUDIENCE"
Expand Down

0 comments on commit fc8ca94

Please sign in to comment.