Skip to content

Commit

Permalink
Merge pull request 'rework saml addon' (#1588) from jakob/friendica-a…
Browse files Browse the repository at this point in the history
…ddons:fix-saml-display-settings into develop

Reviewed-on: https://git.friendi.ca/friendica/friendica-addons/pulls/1588
Reviewed-by: Hypolite Petovan <[email protected]>
  • Loading branch information
MrPetovan committed Jan 23, 2025
2 parents 69e75ef + 0b4aaac commit 1cc5a66
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 32 deletions.
52 changes: 26 additions & 26 deletions saml/lang/C/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -17,82 +17,82 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: saml.php:231
#: saml.php:81
msgid "managed via SAML authentication"
msgstr ""

#: saml.php:246
msgid "Settings statement"
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."
#: saml.php:247
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
#: saml.php:252
msgid "IdP ID"
msgstr ""

#: saml.php:238
msgid ""
"Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/"
"user)."
#: saml.php:253
msgid "Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/user)."
msgstr ""

#: saml.php:242
#: saml.php:257
msgid "Client ID"
msgstr ""

#: saml.php:243
#: saml.php:258
msgid "Identifier assigned to client by the identity provider (IdP)."
msgstr ""

#: saml.php:247
#: saml.php:262
msgid "IdP SSO URL"
msgstr ""

#: saml.php:248
#: saml.php:263
msgid "The URL for your identity provider's SSO endpoint."
msgstr ""

#: saml.php:252
#: saml.php:267
msgid "IdP SLO request URL"
msgstr ""

#: saml.php:253
#: saml.php:268
msgid "The URL for your identity provider's SLO request endpoint."
msgstr ""

#: saml.php:257
#: saml.php:272
msgid "IdP SLO response URL"
msgstr ""

#: saml.php:258
#: saml.php:273
msgid "The URL for your identity provider's SLO response endpoint."
msgstr ""

#: saml.php:262
#: saml.php:277
msgid "SP private key"
msgstr ""

#: saml.php:263
#: saml.php:278
msgid "The private key the addon should use to authenticate."
msgstr ""

#: saml.php:267
#: saml.php:282
msgid "SP certificate"
msgstr ""

#: saml.php:268
#: saml.php:283
msgid "The certficate for the addon's private key."
msgstr ""

#: saml.php:272
#: saml.php:287
msgid "IdP certificate"
msgstr ""

#: saml.php:273
#: saml.php:288
msgid "The x509 certficate for your identity provider."
msgstr ""

#: saml.php:276
#: saml.php:291
msgid "Save Settings"
msgstr ""
1 change: 0 additions & 1 deletion saml/saml.css

This file was deleted.

28 changes: 23 additions & 5 deletions saml/saml.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,36 @@ function saml_install()
Hook::register('footer', __FILE__, 'saml_footer');
}

function saml_head(string &$body)
{
DI::page()->registerStylesheet(__DIR__ . '/saml.css');
}

function saml_footer(string &$body)
{
$fragment = addslashes(BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('saml', 'settings_statement')));
$samlhint = DI::l10n()->t('managed via SAML authentication');
$body .= <<<EOL
<script>
var target=$("#settings-nickname-desc");
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>
EOL;
}
Expand Down

0 comments on commit 1cc5a66

Please sign in to comment.