-
Notifications
You must be signed in to change notification settings - Fork 135
[#3514] Add support for AWS MSK IAM authentication using SASL OAUTHBEARER #4516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
943c016
add aws-msk-iam-sasl-signer-go as requirement
qswinson 4eeaa51
Add MSK IAM auth for control plane
qswinson aae9ec0
Add MSK IAM auth for data plane
qswinson e781313
Update proto/contract
qswinson 487d0dc
fix compile error
qswinson c696d5f
add support for assuming an AWS IAM role to connect to MSK
qswinson 095833c
Merge remote-tracking branch 'source-origin/main' into aws-msk-iam
qswinson 3b0e459
remove change from beta api
qswinson 491975e
more generated files
qswinson f7f07a7
simplify data-plane changes
qswinson ccac58d
fix lint
qswinson 56f5548
second pass at generated code
qswinson c5f9f7a
docs
qswinson 4e12348
use correct protoc version
qswinson 598e215
Merge remote-tracking branch 'source-origin/main' into aws-msk-iam
qswinson f1edfb5
fix unit tests
qswinson 4c5a285
fix formatting
qswinson 0dff494
remove debug
qswinson 6370dba
code review refactor and unit tests
qswinson 43b2924
Merge remote-tracking branch 'source-origin/main' into aws-msk-iam
qswinson a751f26
code review fixes
qswinson 55e8cde
Merge remote-tracking branch 'source-origin/main' into aws-msk-iam
qswinson 6bed236
fix case
qswinson b98f8ed
remove setupEnv and cleanupEnv
qswinson 36ea131
Merge remote-tracking branch 'source-origin/main' into aws-msk-iam
qswinson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2025 The Knative Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package oauth | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
const ( | ||
saslTokenProviderKey = "tokenProvider" | ||
saslRoleARNKey = "roleARN" | ||
saslAWSRegion = "awsRegion" | ||
|
||
// Environment variable names | ||
awsRegionEnvVar = "AWS_REGION" | ||
awsDefaultRegionEnvVar = "AWS_DEFAULT_REGION" | ||
|
||
// Default AWS region | ||
defaultAWSRegion = "us-east-1" | ||
|
||
// Token provider types | ||
mskAccessTokenProvider = "MSKAccessTokenProvider" | ||
mskRoleAccessTokenProvider = "MSKRoleAccessTokenProvider" | ||
|
||
// MSK IAM Auth constants | ||
knativeEventingUserAgent = "knative-eventing" | ||
) | ||
|
||
func getAWSRegion(data map[string][]byte) string { | ||
if region, ok := data[saslAWSRegion]; ok && len(region) > 0 { | ||
return string(region) | ||
} | ||
|
||
awsRegion := os.Getenv(awsRegionEnvVar) | ||
if awsRegion != "" { | ||
return awsRegion | ||
} | ||
|
||
// Fallback to AWS_DEFAULT_REGION if AWS_REGION is not set | ||
awsRegion = os.Getenv(awsDefaultRegionEnvVar) | ||
if awsRegion != "" { | ||
return awsRegion | ||
} | ||
|
||
return defaultAWSRegion | ||
} |
40 changes: 40 additions & 0 deletions
40
control-plane/pkg/security/oauth/msk_access_token_issuer.go
creydr marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2025 The Knative Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package oauth | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-msk-iam-sasl-signer-go/signer" | ||
) | ||
|
||
// mskAccessTokenIssuer implements TokenIssuer for the MSK access token | ||
type mskAccessTokenIssuer struct { | ||
region string | ||
} | ||
|
||
func (m *mskAccessTokenIssuer) IssueToken(ctx context.Context) (string, error) { | ||
token, _, err := signer.GenerateAuthToken(ctx, m.region) | ||
return token, err | ||
} | ||
|
||
func NewMSKAccessTokenIssuer(data map[string][]byte) (*mskAccessTokenIssuer, error) { | ||
region := getAWSRegion(data) | ||
return &mskAccessTokenIssuer{ | ||
region: region, | ||
}, nil | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you been using this with the
source
or also with thebroker
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have been using this only with the broker.