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

Return 500 if Github AppName is empty when enrolling provider #3124

Merged
merged 2 commits into from
Apr 17, 2024
Merged
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
3 changes: 2 additions & 1 deletion internal/controlplane/handlers_oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
// GetAuthorizationURL returns the URL to redirect the user to for authorization
// and the state to be used for the callback. It accepts a provider string
// and a boolean indicating whether the client is a CLI or web client
// nolint:gocyclo
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not happy about this, but this is another day's problem.

func (s *Server) GetAuthorizationURL(ctx context.Context,
req *pb.GetAuthorizationURLRequest) (*pb.GetAuthorizationURLResponse, error) {
entityCtx := engine.EntityFromContext(ctx)
Expand Down Expand Up @@ -143,7 +144,7 @@ func (s *Server) GetAuthorizationURL(ctx context.Context,
var authorizationURL string
if slices.Contains(providerDef.AuthorizationFlows, db.AuthorizationFlowGithubAppFlow) {
gitHubAppConfig := s.cfg.Provider.GitHubApp
if gitHubAppConfig == nil {
if gitHubAppConfig == nil || gitHubAppConfig.AppName == "" {
return nil, status.Errorf(codes.Internal, "error getting GitHub App config: %s", err)
}
authorizationURL = fmt.Sprintf("%s/apps/%v/installations/new?state=%v", githubURL, gitHubAppConfig.AppName, state)
Expand Down