-
Notifications
You must be signed in to change notification settings - Fork 28
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
Changes from 4 commits
b8440ee
2f6a4fa
446050b
42c3d3f
3920ee4
edde501
1e9d276
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,10 @@ class ExternalAuthOptions | |
AUTH_PATH = "/authentication".freeze | ||
|
||
EXT_AUTH_OPTIONS = { | ||
"#{AUTH_PATH}/sso_enabled" => {:label => "Single Sign-On", :logic => true}, | ||
"#{AUTH_PATH}/saml_enabled" => {:label => "SAML", :logic => true}, | ||
"#{AUTH_PATH}/local_login_disabled" => {:label => "Local Login", :logic => false} | ||
"#{AUTH_PATH}/sso_enabled" => {:label => "Single Sign-On", :logic => true}, | ||
"#{AUTH_PATH}/saml_enabled" => {:label => "SAML", :logic => true}, | ||
"#{AUTH_PATH}/oidc_enabled" => {:label => "OIDC", :logic => true}, | ||
"#{AUTH_PATH}/local_login_disabled" => {:label => "Local Login", :logic => false} | ||
}.freeze | ||
|
||
include ManageIQ::ApplianceConsole::Logging | ||
|
@@ -42,6 +43,7 @@ def ask_questions | |
end | ||
end | ||
@updates = {} if selection == skip | ||
@updates = {} unless validate_provider_type | ||
true | ||
end | ||
|
||
|
@@ -79,11 +81,44 @@ def update_configuration(update_hash = nil) | |
if update_hash.present? | ||
say("\nUpdating external authentication options on appliance ...") | ||
params = update_hash.collect { |key, value| "#{key}=#{value}" } | ||
params = enable_provider_type(params) | ||
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 ...") | ||
false | ||
end | ||
|
||
def enable_provider_type(params) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be named with a |
||
if params.include?("/authentication/saml_enabled=true") | ||
provider_type_saml(params) | ||
elsif params.include?("/authentication/oidc_enabled=true") | ||
provider_type_oidc(params) | ||
elsif params.include?("/authentication/oidc_enabled=false") || params.include?("/authentication/saml_enabled=false") | ||
provider_type_none(params) | ||
end | ||
end | ||
|
||
def provider_type_saml(params) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @carbonin Thank you! Will do. |
||
params << "/authentication/oidc_enabled=false" | ||
params << "/authentication/provider_type=saml" | ||
end | ||
|
||
def provider_type_oidc(params) | ||
params << "/authentication/saml_enabled=false" | ||
params << "/authentication/provider_type=oidc" | ||
end | ||
|
||
def provider_type_none(params) | ||
params << "/authentication/oidc_enabled=false" | ||
params << "/authentication/saml_enabled=false" | ||
params << "/authentication/provider_type=none" | ||
end | ||
|
||
# extauth_opts option parser: syntax is key=value,key=value | ||
# key is one of the EXT_AUTH_OPTIONS keys. | ||
# value is one of 1, true, 0 or false. | ||
|
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.
Typo .. should be "enabled"