Merge pull request 'rework saml addon' (#1588) from jakob/friendica-addons:fix-saml-display-settings into develop

Reviewed-on: https://git.friendi.ca/friendica/friendica-addons/pulls/1588
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
develop
Hypolite Petovan 2025-01-23 14:31:49 +01:00
commit 1cc5a6688e
3 changed files with 64 additions and 47 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-18 07:23+0200\n" "POT-Creation-Date: 2025-01-17 03:23+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,82 +17,82 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: saml.php:231 #: saml.php:81
msgid "managed via SAML authentication"
msgstr ""
#: saml.php:246
msgid "Settings statement" msgid "Settings statement"
msgstr "" msgstr ""
#: saml.php:232
msgid ""
"A statement on the settings page explaining where the user should go to "
"change their e-mail and password. BBCode allowed."
msgstr ""
#: saml.php:237
msgid "IdP ID"
msgstr ""
#: saml.php:238
msgid ""
"Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/"
"user)."
msgstr ""
#: saml.php:242
msgid "Client ID"
msgstr ""
#: saml.php:243
msgid "Identifier assigned to client by the identity provider (IdP)."
msgstr ""
#: saml.php:247 #: saml.php:247
msgid "IdP SSO URL" msgid "A statement on the settings page explaining where the user should go to change their e-mail and password. BBCode allowed."
msgstr ""
#: saml.php:248
msgid "The URL for your identity provider's SSO endpoint."
msgstr "" msgstr ""
#: saml.php:252 #: saml.php:252
msgid "IdP SLO request URL" msgid "IdP ID"
msgstr "" msgstr ""
#: saml.php:253 #: saml.php:253
msgid "The URL for your identity provider's SLO request endpoint." msgid "Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/user)."
msgstr "" msgstr ""
#: saml.php:257 #: saml.php:257
msgid "IdP SLO response URL" msgid "Client ID"
msgstr "" msgstr ""
#: saml.php:258 #: saml.php:258
msgid "The URL for your identity provider's SLO response endpoint." msgid "Identifier assigned to client by the identity provider (IdP)."
msgstr "" msgstr ""
#: saml.php:262 #: saml.php:262
msgid "SP private key" msgid "IdP SSO URL"
msgstr "" msgstr ""
#: saml.php:263 #: saml.php:263
msgid "The private key the addon should use to authenticate." msgid "The URL for your identity provider's SSO endpoint."
msgstr "" msgstr ""
#: saml.php:267 #: saml.php:267
msgid "SP certificate" msgid "IdP SLO request URL"
msgstr "" msgstr ""
#: saml.php:268 #: saml.php:268
msgid "The certficate for the addon's private key." msgid "The URL for your identity provider's SLO request endpoint."
msgstr "" msgstr ""
#: saml.php:272 #: saml.php:272
msgid "IdP certificate" msgid "IdP SLO response URL"
msgstr "" msgstr ""
#: saml.php:273 #: saml.php:273
msgid "The URL for your identity provider's SLO response endpoint."
msgstr ""
#: saml.php:277
msgid "SP private key"
msgstr ""
#: saml.php:278
msgid "The private key the addon should use to authenticate."
msgstr ""
#: saml.php:282
msgid "SP certificate"
msgstr ""
#: saml.php:283
msgid "The certficate for the addon's private key."
msgstr ""
#: saml.php:287
msgid "IdP certificate"
msgstr ""
#: saml.php:288
msgid "The x509 certficate for your identity provider." msgid "The x509 certficate for your identity provider."
msgstr "" msgstr ""
#: saml.php:276 #: saml.php:291
msgid "Save Settings" msgid "Save Settings"
msgstr "" msgstr ""

View File

@ -1 +0,0 @@
#settings-form > div:first-of-type, #settings-form > h2:first-of-type, #wrapper_mpassword, #wrapper_email { display: none !important; }

View File

@ -75,18 +75,36 @@ function saml_install()
Hook::register('footer', __FILE__, 'saml_footer'); Hook::register('footer', __FILE__, 'saml_footer');
} }
function saml_head(string &$body)
{
DI::page()->registerStylesheet(__DIR__ . '/saml.css');
}
function saml_footer(string &$body) function saml_footer(string &$body)
{ {
$fragment = addslashes(BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('saml', 'settings_statement'))); $fragment = addslashes(BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('saml', 'settings_statement')));
$samlhint = DI::l10n()->t('managed via SAML authentication');
$body .= <<<EOL $body .= <<<EOL
<script> <script>
var target=$("#settings-nickname-desc"); var target=$("#settings-nickname-desc");
if (target.length) { target.append("<p>$fragment</p>"); } if (target.length) { target.append("<p>$fragment</p>"); }
document.getElementById('id_email').setAttribute('readonly', 'readonly');
var saml_hint = document.createElement("span");
var saml_hint_text = document.createTextNode('$samlhint');
saml_hint.appendChild(saml_hint_text);
document.getElementById('id_email').parentNode.insertBefore(saml_hint, document.getElementById('id_email').nextSibling);
// Frio theme
if ( document.getElementById('password-settings-collapse') != null ) {
document.getElementById('password-settings-collapse').replaceChildren(saml_hint.cloneNode(true));
}
if ( document.getElementById('id_mpassword_wrapper') != null ) {
document.getElementById('id_mpassword_wrapper').parentNode.appendChild(saml_hint.cloneNode(true));
document.getElementById('id_mpassword_wrapper').remove();
document.getElementById('id_email').nextElementSibling.classList.add('help-block');
}
// Vier theme
if ( document.getElementById('wrapper_mpassword') != null ) {
document.getElementById('wrapper_mpassword').remove();
document.getElementById('id_email').nextElementSibling.classList.add('field_help');
}
if ( document.getElementById('wrapper_password') != null ) {
document.getElementById('wrapper_password').parentNode.replaceChildren(saml_hint.cloneNode(true));
}
</script> </script>
EOL; EOL;
} }