-
Notifications
You must be signed in to change notification settings - Fork 66
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 GitHub IDP validations #1907
Add GitHub IDP validations #1907
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## github_identity_provider #1907 +/- ##
============================================================
+ Coverage 38.62% 38.79% +0.16%
============================================================
Files 356 355 -1
Lines 44994 45287 +293
============================================================
+ Hits 17380 17570 +190
- Misses 27086 27190 +104
+ Partials 528 527 -1 ☔ View full report in Codecov by Sentry. |
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
case v1alpha1.GitHubUsernameID: | ||
break | ||
default: | ||
return nil, fmt.Errorf("invalid spec.claims.username") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it really can't happen, do we just want to log
the error?
If an error here does happen, then it is a user configuration
error, so we don't really want to return a Sync()
error and trigger the loop again. A user has to step in and fix the config.
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher_test.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
2afbe31
to
d125f75
Compare
d125f75
to
36b5246
Compare
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Show resolved
Hide resolved
|
||
// Should there be some sort of catch-all condition to capture this? | ||
// This does not actually prevent a GitHub IDP from being added to the cache. | ||
groupNameAttribute, usernameAttribute, userAndGroupErr := validateUserAndGroupAttributes(upstream) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should have a condition to capture this.
return conditions, hostWithHttps, c.httpClientBuilder(certPool), conn.Close() | ||
} | ||
|
||
func validateUserAndGroupAttributes(upstream *v1alpha1.GitHubIdentityProvider) (v1alpha1.GitHubGroupNameAttribute, v1alpha1.GitHubUsernameAttribute, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return a condition as well from this func?
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher_test.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher_test.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher_test.go
Outdated
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher_test.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Outdated
Show resolved
Hide resolved
d028945
to
9ef688a
Compare
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher_test.go
Show resolved
Hide resolved
internal/controller/supervisorconfig/githubupstreamwatcher/github_upstream_watcher.go
Show resolved
Hide resolved
buildLogForUpdatingTLSConfigurationValid("minimal-idp-name", "True", "Success", "spec.githubAPI.tls.certificateAuthorityData is valid"), | ||
buildLogForUpdatingGitHubConnectionValid("minimal-idp-name", "True", "Success", `spec.githubAPI.host (\"%s\") is reachable and TLS verification succeeds`, *validFilledOutIDP.Spec.GitHubAPI.Host), | ||
buildLogForUpdatingPhase("minimal-idp-name", "Error"), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more at the end, since update status
is the last thing the controller does:
{
name: "When update status request fails the controller will resync",
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to fake out these K8s requests so that they return errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't too bad. See this example:
9ef688a
to
c9b61ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, lets move this forward!
Add GitHub IDP validations