Skip to content

Commit

Permalink
move function to api
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrato committed Oct 24, 2024
1 parent b03d06e commit ff60a0f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
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()
}
4 changes: 2 additions & 2 deletions tool/tctl/common/plugin/entraid.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

pluginspb "github.com/gravitational/teleport/api/gen/proto/go/teleport/plugins/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/e/lib/entraid"
entraapiutils "github.com/gravitational/teleport/api/utils/entraid"
"github.com/gravitational/teleport/lib/integrations/azureoidc"
"github.com/gravitational/teleport/lib/utils/oidc"
"github.com/gravitational/teleport/lib/web/scripts/oneoff"
Expand Down Expand Up @@ -211,7 +211,7 @@ func (p *PluginsCommand) InstallEntra(ctx context.Context, args installPluginArg
},
},
Display: "Entra ID",
EntityDescriptorURL: entraid.FederationMetadataURL(settings.tenantID, settings.clientID),
EntityDescriptorURL: entraapiutils.FederationMetadataURL(settings.tenantID, settings.clientID),
})
if err != nil {
return trace.Wrap(err, "failed to create SAML connector")
Expand Down

0 comments on commit ff60a0f

Please sign in to comment.