-
Notifications
You must be signed in to change notification settings - Fork 100
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
Enhancement to optionally fetch the OIDCAuthIntrospectionURL #571
Enhancement to optionally fetch the OIDCAuthIntrospectionURL #571
Conversation
20eb63e
to
5f777be
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.
High level review to start. I figure it's easier to get this into the right place in the source, then we can tackle the implementation.
if spec.OIDCProviderURL == "" || spec.OIDCClientSecret == "" { | ||
errs = append(errs, "HttpdAuthConfig or both OIDCProviderURL and OIDCClientSecret must be provided for openid-connect authentication") | ||
} else { | ||
// If the OAuth Introspection URL was not specified, let's try to fetch it from the Provider URL |
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 don't really think this belongs in Validate
.
My intention here was to make this act kind of like an AR validation where we wouldn't change the object we're validating and wouldn't take any further action.
I think it would be better to make the introspection URL optional and fetch it if it was not provided. Then if we fail to fetch it at that point we can error out of reconcile.
@@ -283,6 +286,28 @@ func init() { | |||
SchemeBuilder.Register(&ManageIQ{}, &ManageIQList{}) | |||
} | |||
|
|||
func fetchIntrospectionUrl(providerUrl string) (introspectionUrl string, errMsg string) { |
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 doesn't belong in the v1alpha1
package. I think this all should go at least into the controller, possibly into the httpd component.
@abellotti @carbonin let's get this one over the finish line, so we can call ManageIQ/manageiq#19867 complete for Jansa (I removed the lower priority nice-to-haves from the list on that issue). |
Alberto and I chatted about the direction this should go last week. That new direction would have conflicted with #572, but since that was merged today we should be able to make more progress here. |
I'm assuming that #572 is jansa/no, though, right? So will it still have issues on backport? |
the Provider Metadata URL if not provided to us.
…on code and into the config map generation code.
5f777be
to
f5d658d
Compare
/cc @carbonin latest changes on master, I will create a separate PR for Jansa. Thanks for all your help!! |
The Jansa PR: #582 |
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.
Can you add a bit to the comment in the ManageIQSpec struct about how we will fetch the introspection URL if it isn't provided?
Few minor comments. Otherwise looks good
@@ -81,7 +84,16 @@ func Ingress(cr *miqv1alpha1.ManageIQ, scheme *runtime.Scheme) (*extensionsv1bet | |||
return ingress, f | |||
} | |||
|
|||
func HttpdConfigMap(cr *miqv1alpha1.ManageIQ, scheme *runtime.Scheme) (*corev1.ConfigMap, controllerutil.MutateFn) { | |||
func HttpdConfigMap(cr *miqv1alpha1.ManageIQ, scheme *runtime.Scheme) (*corev1.ConfigMap, controllerutil.MutateFn, 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.
I think we can lose this leading whitespace.
if err != nil { | ||
return nil, nil, err | ||
} | ||
(&cr.Spec).OIDCOAuthIntrospectionURL = introspectionURL |
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.
You don't need the & and parens here. cr.Spec.OIDCOAuthIntrospectionURL = introspectionURL
will do what you want as cr
is already a pointer.
I assume you lifted this from Initialize
?
If that's the case that's different because we're using an intermediate local to store the spec so we don't need m.Spec
everywhere.
} | ||
|
||
if result["token_introspection_endpoint"] == nil { | ||
return "", fmt.Errorf("%s - token_introspection_endpoint is missing", errMsg) |
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.
Maybe "token_introspection_endpoint is missing from response"?
I don't think I would understand what this was saying as is.
78e720a
to
cbc1236
Compare
- Added comments on the fetching of the introspection URL if not specified. - Removed unnecessary white spaces - Defining introspection URL via cr.Spec... = instead of (&cr.Spec) - Clarified error message for missing token_introspection_endpoint
cbc1236
to
aec43e3
Compare
Checked commits abellotti/manageiq-pods@f94430f~...aec43e3 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint **
|
ok @carbonin I |
Backported to jansa via #582 |
Solves: #512