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 support to Enable OpenID-Connect in the appliance console. #48

Merged
merged 7 commits into from
Jul 20, 2018

Conversation

jvlcek
Copy link
Member

@jvlcek jvlcek commented Jun 27, 2018

https://www.pivotaltracker.com/n/projects/1610127/stories/121849185
https://www.pivotaltracker.com/n/projects/1610127/stories/121849185

The change introduced by this PR will allow the appliance console support of the OpenID Connect protocol.

This is a WIP PR for now as we only support OpenID in the pods now with the configmap generator. Standalone appliance apache config does not support OpenID (i.e. we don't have the separate Apache templates & the needed manual steps in http://manageiq.org/docs/reference/ under Authentication).

The change introduced by this PR is reliant on the following work for full OpenID Connect support:

#16495
ManageIQ/manageiq-ui-classic#2855

@jvlcek
Copy link
Member Author

jvlcek commented Jun 27, 2018

@miq-bot add_label authentication

@miq-bot
Copy link
Member

miq-bot commented Jun 27, 2018

@jvlcek Cannot apply the following label because they are not recognized: authentication

@jvlcek
Copy link
Member Author

jvlcek commented Jun 27, 2018

@miq-bot add_label gaprindashvili/no

@jvlcek
Copy link
Member Author

jvlcek commented Jun 27, 2018

@miq-bot add_label wip

@jvlcek jvlcek changed the title Add support to Enable OpenID-Connect in the appliance console. [WIP] Add support to Enable OpenID-Connect in the appliance console. Jun 27, 2018
@miq-bot
Copy link
Member

miq-bot commented Jun 27, 2018

@jvlcek Cannot apply the following label because they are not recognized: gaprindashvili/no

@miq-bot miq-bot added the wip label Jun 27, 2018
result = ManageIQ::ApplianceConsole::Utilities.rake_run("evm:settings:set", params)
raise parse_errors(result).join(', ') if result.failure?
end
end

def never_enable_saml_and_oidc(params)
if params.include?("/authentication/oidc_enabled=true") && params.include?("/authentication/saml_enabled=true")
say("\nWARNING: Both SAML and OIDC can not be enable. SAML will be enabled ...")
Copy link
Member

Choose a reason for hiding this comment

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

Typo s/enable/enabled/

result = ManageIQ::ApplianceConsole::Utilities.rake_run("evm:settings:set", params)
raise parse_errors(result).join(', ') if result.failure?
end
end

def never_enable_saml_and_oidc(params)
Copy link
Member

Choose a reason for hiding this comment

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

Methods that alter the parameter passed in should end in a !

end
end

def remove_oidc(params)
Copy link
Member

Choose a reason for hiding this comment

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

These should also all end in ! to show that the parameter is being altered.

end

if params.include?("/authentication/saml_enabled=true")
params = remove_oidc(params)
Copy link
Member

Choose a reason for hiding this comment

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

If you are editing the hash passed in, you don't need to re-assign.

result = ManageIQ::ApplianceConsole::Utilities.rake_run("evm:settings:set", params)
raise parse_errors(result).join(', ') if result.failure?
end
end

def never_enable_saml_and_oidc(params)
if params.include?("/authentication/oidc_enabled=true") && params.include?("/authentication/saml_enabled=true")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what the user experience is here, but why can this even happen? Shouldn't we ask for the user to specify only one external auth type? Or check for this as they are selecting the options rather than assuming one way or the other after the fact?

Either way I think it would be better to fail here rather than just picking one of the options they said they want to configure.

Copy link
Member Author

@jvlcek jvlcek Jun 28, 2018

Choose a reason for hiding this comment

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

The logic in external_auth_options.rb expects all the options to be a toggle of a true or false value. The new authentication setting provider_type, with possible values of oidc, saml or none, is used by the UI to toggle oidc_enabled and saml_enabled.

After speaking with @abellotti about this, the agreed approach is to get the needed changes in that will make it work even if not elegant and avoid a larger refactoring, since the fate of OIDC on non-podified appliances is not finalized.

Because the appliance_console loops allowing the user to reselect options the params array could have many combinations. Without reworking external_auth_options.rb the solution I presented ensures correct results.

That said, I could error out if both oidc_enabled and saml_enabled are true.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh and thanks for taking a look! @carbonin

Copy link
Member

Choose a reason for hiding this comment

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

Okay, then I think a validate! which will error if there is an incompatible combination selected is a better experience than possibly configuring something the user may not have intended.

Copy link
Member Author

Choose a reason for hiding this comment

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

@carbonin

The only incompatible combination it so enable both oidc and saml. I will add a validate! for that and error out.

Thanks!

result = ManageIQ::ApplianceConsole::Utilities.rake_run("evm:settings:set", params)
raise parse_errors(result).join(', ') if result.failure?
end
end

def validate_provider_type
return true unless @updates["/authentication/oidc_enabled"] == true && @updates["/authentication/saml_enabled"] == true
say("\Error: Both SAML and OIDC can not be enable ...")
Copy link
Member

Choose a reason for hiding this comment

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

Typo .. should be "enabled"

false
end

def enable_provider_type(params)
Copy link
Member

Choose a reason for hiding this comment

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

Since you're altering the passed-in hash here, I think this method should be named enable_provider_type!

false
end

def enable_provider_type(params)
Copy link
Member

@carbonin carbonin Jun 28, 2018

Choose a reason for hiding this comment

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

This should be named with a ! because you're altering the parameter passed into the method. (same with all the provider_type_* methods)

end
end

def provider_type_saml(params)
Copy link
Member

Choose a reason for hiding this comment

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

I think I would prefer these have a method name that uses a verb as it's altering the hash. A noun method feels more like it's returning a value retrieved from somewhere else.

Also all of these should be named with a ! for the same reason as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

@carbonin Thank you! Will do.

@miq-bot
Copy link
Member

miq-bot commented Jul 2, 2018

Checked commits jvlcek/manageiq-appliance_console@b8440ee~...1e9d276 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🍰

@jvlcek jvlcek changed the title [WIP] Add support to Enable OpenID-Connect in the appliance console. Add support to Enable OpenID-Connect in the appliance console. Jul 17, 2018
@jvlcek
Copy link
Member Author

jvlcek commented Jul 17, 2018

@carbonin and @abellotti Can the failing codeclimate Complexity issue be waved?
Method ask_questions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring

This PR and ManageIQ/manageiq#16567 need to be merged together.

@miq-bot miq-bot removed the wip label Jul 17, 2018
@carbonin carbonin self-assigned this Jul 20, 2018
@carbonin carbonin added this to the Sprint 91 Ending Jul 30, 2018 milestone Jul 20, 2018
@carbonin carbonin merged commit 0638acf into ManageIQ:master Jul 20, 2018
@jvlcek jvlcek deleted the openidc branch January 18, 2021 17:45
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