-
Notifications
You must be signed in to change notification settings - Fork 2.1k
OIDC auth support for Azure auto-discovery #61494
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
10 commits
Select commit
Hold shift + click to select a range
a1e54b6
feat: add support for Azure OIDC integration auth for discovery service
Tener cb09dea
docs: improve documentation for getAzureClients function
Tener 5974a89
feat: add integration field to Azure fetcher configurations
Tener b7d0c56
Merge branch 'master' into tener/azure-oidc-discovery-auth
Tener b1b378e
update expected test result
Tener 3b47830
update another expected test result; update said test to use Eventual…
Tener 52a81d0
lint fix
Tener aae41bd
Merge branch 'master' into tener/azure-oidc-discovery-auth
Tener 826e607
Merge branch 'master' into tener/azure-oidc-discovery-auth
Tener f94927d
Merge branch 'master' into tener/azure-oidc-discovery-auth
Tener File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| // Teleport | ||
| // Copyright (C) 2025 Gravitational, Inc. | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| package cloud | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/gravitational/trace" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/gravitational/teleport/api/defaults" | ||
| "github.com/gravitational/teleport/api/types" | ||
| ) | ||
|
|
||
| type testAzureOIDCCredentials struct { | ||
| integration types.Integration | ||
| } | ||
|
|
||
| func (m *testAzureOIDCCredentials) GenerateAzureOIDCToken(ctx context.Context, integration string) (string, error) { | ||
| return "dummy-oidc-token", nil | ||
| } | ||
|
|
||
| func (m *testAzureOIDCCredentials) GetIntegration(ctx context.Context, name string) (types.Integration, error) { | ||
| if m.integration == nil || m.integration.GetName() != name { | ||
| return nil, trace.NotFound("integration %q not found", name) | ||
| } | ||
| return m.integration, nil | ||
| } | ||
|
|
||
| func TestWithAzureIntegrationCredentials(t *testing.T) { | ||
| const integrationName = "azure" | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| integration types.Integration | ||
| wantErr string | ||
| }{ | ||
| { | ||
| name: "valid azure integration", | ||
| integration: &types.IntegrationV1{ | ||
| ResourceHeader: types.ResourceHeader{ | ||
| Kind: types.KindIntegration, | ||
| SubKind: types.IntegrationSubKindAzureOIDC, | ||
| Version: types.V1, | ||
| Metadata: types.Metadata{ | ||
| Name: integrationName, | ||
| Namespace: defaults.Namespace, | ||
| }, | ||
| }, | ||
| Spec: types.IntegrationSpecV1{ | ||
| SubKindSpec: &types.IntegrationSpecV1_AzureOIDC{ | ||
| AzureOIDC: &types.AzureOIDCIntegrationSpecV1{ | ||
| ClientID: "baz-quux", | ||
| TenantID: "foo-bar", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: "integration not found", | ||
| integration: nil, | ||
| wantErr: `integration "azure" not found`, | ||
| }, | ||
| { | ||
| name: "invalid integration type", | ||
| integration: &types.IntegrationV1{ | ||
| ResourceHeader: types.ResourceHeader{ | ||
| Kind: types.KindIntegration, | ||
| SubKind: types.IntegrationSubKindAWSOIDC, | ||
| Version: types.V1, | ||
| Metadata: types.Metadata{ | ||
| Name: "azure", | ||
| Namespace: defaults.Namespace, | ||
| }, | ||
| }, | ||
| Spec: types.IntegrationSpecV1{ | ||
| SubKindSpec: &types.IntegrationSpecV1_AWSOIDC{ | ||
| AWSOIDC: &types.AWSOIDCIntegrationSpecV1{ | ||
| RoleARN: "arn:aws:iam::123456789012:role/teleport", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| wantErr: `expected "azure" to be an "azure-oidc" integration, was "aws-oidc" instead`, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| opt := WithAzureIntegrationCredentials(integrationName, &testAzureOIDCCredentials{ | ||
| integration: tt.integration, | ||
| }) | ||
| clients, err := NewAzureClients(opt) | ||
| require.NoError(t, err) | ||
|
|
||
| credential, err := clients.GetAzureCredential() | ||
|
|
||
| if tt.wantErr == "" { | ||
| require.NoError(t, err) | ||
| require.NotNil(t, credential) | ||
| } else { | ||
| require.ErrorContains(t, err, tt.wantErr) | ||
| require.Nil(t, credential) | ||
| } | ||
| }) | ||
| } | ||
| } |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.