diff --git a/assets/stylesheets/login.css.redminebuttonstyle b/assets/stylesheets/login.css.redminebuttonstyle new file mode 100644 index 0000000..dc5becf --- /dev/null +++ b/assets/stylesheets/login.css.redminebuttonstyle @@ -0,0 +1,20 @@ +#saml-login { + margin: 1em auto 2em auto; + padding: 20px; + width: 340px; + border: 1px solid #FDBF3B; + background-color: #FFEBC1; + border-radius: 4px; + box-sizing: border-box; +} + +#saml-login form button[type='submit'] { + display: block; + width: 100%; +} + +#saml-login form button[type='submit']:hover { + background-color: #c7c6c5 !important; +} + +#login-form table { margin-top: 2em; } diff --git a/config/locales/en.yml b/config/locales/en.yml index 14b34f3..bb7751d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,6 +1,6 @@ en: error_saml_authenticity_error: SAML authentication error - error_saml_invalid_ticket: Invalid SAML ticket + error_saml_invalid_ticket: Invalid SAML ticket (check IDP cert /IDP cert fingerprint) label_onthefly_creation: Create users automatically? label_replace_redmine_login: Replace Redmine login page label_saml_enabled: Enable SAML authentication diff --git a/lib/redmine_saml/base.rb b/lib/redmine_saml/base.rb index 3007147..dea5760 100644 --- a/lib/redmine_saml/base.rb +++ b/lib/redmine_saml/base.rb @@ -61,7 +61,7 @@ def validated_configuration? end def required_attribute_mapping - %i[login firstname lastname mail] + %i[login firstname lastname mail admin] end def validate_configuration! diff --git a/lib/redmine_saml/patches/user_patch.rb b/lib/redmine_saml/patches/user_patch.rb index e8ce90f..cb5b7a4 100644 --- a/lib/redmine_saml/patches/user_patch.rb +++ b/lib/redmine_saml/patches/user_patch.rb @@ -25,6 +25,12 @@ def find_or_create_from_omniauth(omniauth) user.login = user_attributes[:login].presence || user_attributes[:mail] user.language = Setting.default_language user.activate + if user_attributes[:admin].present? + user.admin = user_attributes[:admin] + else + user.admin = 'false' + end + user.save! user.reload end @@ -35,6 +41,11 @@ def find_or_create_from_omniauth(omniauth) user.admin = user_attributes[:admin] if user_attributes[:admin].present? end + # Debug : check attributes retrueved by the RedmineSaml.user_attributes_from_saml method + # File.write('/tmp/attributes.txt', user_attributes) + + + RedmineSaml.on_login_callback&.call omniauth, user user