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

Add default GitHub API URLs to SSO connector #31397

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions api/types/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
)

const (
githubURL = "https://github.com"
githubAPIURL = "https://api.github.com"
GithubURL = "https://github.com"
GithubAPIURL = "https://api.github.com"
)

// GithubConnector defines an interface for a Github OAuth2 connector
Expand Down Expand Up @@ -279,12 +279,12 @@ func (c *GithubConnectorV3) SetDisplay(display string) {

// GetEndpointURL returns the endpoint URL
func (c *GithubConnectorV3) GetEndpointURL() string {
return githubURL
return GithubURL
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is anyone else curious why this always returns a constant? Is this because SSO for self-hosted github is an enterprise-only feature?

}

// GetEndpointURL returns the API endpoint URL
func (c *GithubConnectorV3) GetAPIEndpointURL() string {
return githubAPIURL
return GithubAPIURL
}

// MapClaims returns a list of logins based on the provided claims,
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/access-controls/sso/github-sso.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ kind: github
metadata:
name: github
spec:
api_endpoint_url: ""
api_endpoint_url: https://api.github.com
client_id: <client-id>
client_secret: <client-secret>
display: GitHub
endpoint_url: ""
endpoint_url: https://github.com
redirect_url: https://<proxy-address>/v1/webapi/github/callback
teams_to_logins: null
teams_to_roles:
Expand Down
11 changes: 9 additions & 2 deletions tool/tctl/sso/configure/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ func addGithubCommand(cmd *SSOConfigureCommand) *AuthKindCommand {
sub.Flag("display", "Sets the connector display name.").StringVar(&spec.Display)
sub.Flag("id", "GitHub app client ID.").PlaceHolder("ID").Required().StringVar(&spec.ClientID)
sub.Flag("secret", "GitHub app client secret.").Required().PlaceHolder("SECRET").StringVar(&spec.ClientSecret)
sub.Flag("endpoint-url", "Endpoint URL for GitHub instance.").StringVar(&spec.EndpointURL)
sub.Flag("api-endpoint-url", "API endpoint URL for GitHub instance.").StringVar(&spec.APIEndpointURL)
sub.Flag("endpoint-url", "Endpoint URL for GitHub instance.").
PlaceHolder("URL").
Default(types.GithubURL).
StringVar(&spec.EndpointURL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a URL, should we use URLVar instead of StringVar?


sub.Flag("api-endpoint-url", "API endpoint URL for GitHub instance.").
PlaceHolder("URL").
Default(types.GithubAPIURL).
StringVar(&spec.APIEndpointURL)

// auto
sub.Flag("redirect-url", "Authorization callback URL.").PlaceHolder("URL").StringVar(&spec.RedirectURL)
Expand Down