Skip to content
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

[entraid] add setup script for offline clusters. #47863

Merged
merged 9 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions api/utils/entraid/federation_metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2024 Gravitational, Inc.
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 entraid

import (
"net/url"
"path"
)

// FederationMetadataURL returns the URL for the federation metadata endpoint
func FederationMetadataURL(tenantID, appID string) string {
return (&url.URL{
Scheme: "https",
Host: "login.microsoftonline.com",
Path: path.Join(tenantID, "federationmetadata", "2007-06", "federationmetadata.xml"),
RawQuery: url.Values{
"appid": {appID},
}.Encode(),
}).String()
}
3 changes: 3 additions & 0 deletions lib/config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ type IntegrationConfAzureOIDC struct {
// When this is true, the integration script will produce
// a cache file necessary for TAG synchronization.
AccessGraphEnabled bool

// SkipOIDCConfiguration is a flag indicating that OIDC configuration should be skipped.
SkipOIDCConfiguration bool
}

// IntegrationConfDeployServiceIAM contains the arguments of
Expand Down
10 changes: 7 additions & 3 deletions lib/integrations/azureoidc/enterprise_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var appRoles = []string{
// - Provides Teleport with OIDC authentication to Azure
// - Is given the permissions to access certain Microsoft Graph API endpoints for this tenant.
// - Provides SSO to the Teleport cluster via SAML.
func SetupEnterpriseApp(ctx context.Context, proxyPublicAddr string, authConnectorName string) (string, string, error) {
func SetupEnterpriseApp(ctx context.Context, proxyPublicAddr string, authConnectorName string, skipOIDCSetup bool) (string, string, error) {
var appID, tenantID string

tenantID, err := getTenantID()
Expand Down Expand Up @@ -120,8 +120,12 @@ func SetupEnterpriseApp(ctx context.Context, proxyPublicAddr string, authConnect
}
}

if err := createFederatedAuthCredential(ctx, graphClient, *app.ID, proxyPublicAddr); err != nil {
return appID, tenantID, trace.Wrap(err, "failed to create an OIDC federated auth credential")
// Skip OIDC setup if requested.
// This is useful for clusters that can't use OIDC because they are not reachable from the public internet.
if !skipOIDCSetup {
if err := createFederatedAuthCredential(ctx, graphClient, *app.ID, proxyPublicAddr); err != nil {
return appID, tenantID, trace.Wrap(err, "failed to create an OIDC federated auth credential")
}
}

acsURL, err := url.Parse(proxyPublicAddr)
Expand Down
Loading
Loading