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 pinniped_supported_identity_provider_types to the IDP discovery endpoint #1928

Merged
merged 4 commits into from May 16, 2024

Conversation

joshuatcasey
Copy link
Member

Add pinniped_supported_identity_provider_types to the IDP discovery endpoint

Copy link

codecov bot commented Apr 30, 2024

Codecov Report

Attention: Patch coverage is 88.29114% with 37 lines in your changes are missing coverage. Please review.

Project coverage is 29.62%. Comparing base (6b3f175) to head (7787885).

Files Patch % Lines
cmd/pinniped/cmd/oidc_client_options.go 0.00% 24 Missing ⚠️
pkg/oidcclient/login.go 93.50% 7 Missing and 3 partials ⚠️
.../controller/kubecertagent/mocks/mockdynamiccert.go 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1928      +/-   ##
==========================================
+ Coverage   29.40%   29.62%   +0.22%     
==========================================
  Files         348      350       +2     
  Lines       58499    58730     +231     
==========================================
+ Hits        17200    17400     +200     
- Misses      40785    40813      +28     
- Partials      514      517       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cfryanr
Copy link
Member

cfryanr commented May 1, 2024

lgtm. Should we do the CLI changes in the same PR, or a new PR?

cfryanr
cfryanr previously approved these changes May 1, 2024
@joshuatcasey
Copy link
Member Author

joshuatcasey commented May 2, 2024

lgtm. Should we do the CLI changes in the same PR, or a new PR?

I'm not really sure exactly how we should translate this into CLI changes at the moment. Right now the best place to use it seems to be in pinniped get kubeconfig help text, but calling this endpoint in order to generate help text seems a little awkward. That command at the moment only conditionally calls the endpoint at all.

@joshuatcasey
Copy link
Member Author

joshuatcasey commented May 2, 2024

I'm actually not super clear how the CLI could best make use of this information for help text purposes.

The pinniped get kubeconfig command has a flag --oidc-issuer, which can be used to look up discovery information. If that flag is not set, it will inspect the JWTAuthenticator for the issuer. Even then it will only perform discovery if it needs additional information such as which IDPs are available.

Perhaps another way we could make use of the supported IDP types is by checking the --upstream-identity-provider-type against pinniped_supported_identity_provider_types? If a user calls pinniped get kubeconfig --upstream-identity-provider-name=<> --upstream-identity-provider-type=<> --upstream-identity-provider-flow=<> all specified, current logic will not perform upstream discovery at all. We'd likely want to rethink how this works.

@cfryanr cfryanr dismissed their stale review May 2, 2024 23:30

We changed the scope of this PR to now also include the CLI code

@joshuatcasey joshuatcasey force-pushed the jtc/add-idp-type-discovery branch 8 times, most recently from 97fc3cb to a8a76ef Compare May 7, 2024 02:59
@joshuatcasey joshuatcasey force-pushed the jtc/add-idp-type-discovery branch 5 times, most recently from 936c9b1 to ddcf079 Compare May 11, 2024 00:17
@cfryanr
Copy link
Member

cfryanr commented May 15, 2024

Cases that we should make sure are covered:

  • The issuer is not a Supervisor
  • The issuer is a Supervisor but the user did not specify any IDP name/type
  • The issuer is a Supervisor and the user specified an IDP name/type
  • The issuer is an old Supervisor which does not have the new discovery data
  • The issuer is a new Supervisor which has the new discovery data
  • The issuer is a Supervisor using the backwards compatible FederationDomain mode where there are no IDPs listed on the FederationDomain CR
  • The issuer is a Supervisor using the modern FederationDomain mode where the user lists IDPs on the FederationDomain CR

What else should we consider?

Comment on lines +978 to +983
// This check confirms that the issuer is hosting the IDP discovery document, which would always be the case for
// Pinniped Supervisor. Since there are checks above to confirm that the issuer uses HTTPS, IDP discovery will
// always use HTTPS.
if !strings.HasPrefix(pinnipedSupervisorClaims.SupervisorDiscovery.PinnipedIDPsEndpoint, h.issuer) {
return fmt.Errorf("the Pinniped IDP discovery document must always be hosted by the issuer: %q", h.issuer)
}
Copy link
Member

@cfryanr cfryanr May 15, 2024

Choose a reason for hiding this comment

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

Rather than check that the endpoint is on the same server, wouldn't it be sufficient to just check that it is an https URL? If the user is trusting this issuer, then the user should also be trusting any URLs that the issuer is pointing them to for IDP discovery.

It's still important that the URL is https though, because plain http would break that chain of trust (which starts with the original issuer https URL and CA bundle), so the client should not follow plain http URLs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the idea is that this client should make sure that Pinniped's IDP discovery is hosted on the same FederationDomain. Since this will always be true for a Pinniped Supervisor, it seems the natural thing to check here.

joshuatcasey and others added 3 commits May 16, 2024 12:55
…_supported_identity_provider_types

Co-authored-by: Joshua Casey <joshuatcasey@gmail.com>
…he flowtype from the Supervisor's IDP discovery

Co-authored-by: Joshua T Casey <caseyj@vmware.com>
@cfryanr cfryanr enabled auto-merge May 16, 2024 18:06
Co-authored-by: Ryan Richard <richardry@vmware.com>
@cfryanr cfryanr merged commit 3fe3cf7 into main May 16, 2024
43 checks passed
@cfryanr cfryanr deleted the jtc/add-idp-type-discovery branch May 16, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants