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

[EV-5401] Add oidc certificate and configs for queryserver #3599

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

ti-afra
Copy link
Contributor

@ti-afra ti-afra commented Nov 19, 2024

Description

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

@@ -382,6 +383,43 @@ func (r *ReconcileAPIServer) Reconcile(ctx context.Context, request reconcile.Re
// Render the desired objects from the CRD and create or update them.
reqLogger.V(3).Info("rendering components")

var authenticationCR *operatorv1.Authentication
// Fetch the Authentication spec. If present, we use to configure user authentication.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Fetch the Authentication spec. If present, we use to configure user authentication.
// Fetch the Authentication spec. If present, we use it to configure user authentication.

nil, reqLogger)
return reconcile.Result{}, nil
}
trustedBundle.AddCertificates(certificate)
Copy link
Member

@rene-dekker rene-dekker Nov 19, 2024

Choose a reason for hiding this comment

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

Theoretically speaking, trustedBundle can be nil here. I'd suggest creating the bundle after this line:

if installationSpec.Variant == operatorv1.TigeraSecureEnterprise {
+ trustedBundle = certificateManager.CreateTrustedBundle()

Then change the following line:

- trustedBundle = certificateManager.CreateTrustedBundle(prometheusCertificate)
+ trustedBundle.AddCertificates(prometheusCertificate)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for catching this 👍

@ti-afra ti-afra force-pushed the qs-env branch 2 times, most recently from 217e5ca to d12fa3b Compare November 19, 2024 18:53

hostnameParts := strings.Split(hostname, ".")

if len(hostnameParts) == 2 {
Copy link
Member

Choose a reason for hiding this comment

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

This will turn an external host "idp.org" into a service of ns=idp and name=org. Is that really desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will, but there is not rule saying that your namespace cannot be called "org" 😁
I thought this is not a bad compromise unless we want to query the cluster and check if namespace org already exists or not.

Copy link
Member

Choose a reason for hiding this comment

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

Given the time sensitivity of the issue I propose we assume that the idp is external and create egress according to that assumption. As a follow-up we can explore adding the right egress rule in the case that it isn't. OIDC type tigera is something that we don't expect anyone uses in the wild, and in the case of cloud, they won't be needing this egress rule as the queryserver won't get any traffic from idp issued bearer tokens.

// the result will include an egress rules with the urlString passed in:
// 1. egress rule: egress rule assuming the oidc is external to the cluster
func GetOIDCEgressRule(urlString string) v3.Rule {
parsedURL, err := url.Parse(urlString)
Copy link
Member

@rene-dekker rene-dekker Nov 20, 2024

Choose a reason for hiding this comment

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

Do we check already somewhere that this can be parsed? We don't want this panic to ever happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this has to be check when initializing the authentication cr values. Let me check it.

@ti-afra ti-afra force-pushed the qs-env branch 2 times, most recently from f1e67d1 to e0c593b Compare November 20, 2024 03:14
}

if keyValidatorConfig != nil {
if _, err := url.Parse(keyValidatorConfig.Issuer()); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I see now that this check is not necessary.
The constructor for KeyValidatorConfig will create a well known config, which is obtained through making a request to the URL.
This means that we can remove this check again.

@@ -442,6 +443,13 @@ func (r *ReconcileCompliance) Reconcile(ctx context.Context, request reconcile.R
return reconcile.Result{}, err
}

if keyValidatorConfig != nil {
if _, err := url.Parse(keyValidatorConfig.Issuer()); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I see now that this check is not necessary.
The constructor for KeyValidatorConfig will create a well known config, which is obtained through making a request to the URL.
This means that we can remove this check again.

Copy link
Member

@rene-dekker rene-dekker left a comment

Choose a reason for hiding this comment

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

lgtm

@rene-dekker rene-dekker merged commit fa59ba1 into tigera:master Nov 20, 2024
5 checks passed
@ti-afra ti-afra deleted the qs-env branch November 20, 2024 19:18
@ti-afra ti-afra changed the title Add oidc certificate and configs for queryserver [EV-5401] Add oidc certificate and configs for queryserver Nov 20, 2024
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.

3 participants