diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index d6b6a80..cb66479 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,18 +1,18 @@ -name: 'build-test' -on: - pull_request: # Triggers on pull requests - push: # Triggers on pushes to specified branches - branches: - - main - - development - - 'releases/*' # All branches under releases - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Run plugin check - uses: wordpress/plugin-check-action@v1 \ No newline at end of file +name: 'build-test' +on: + pull_request: # Triggers on pull requests + push: # Triggers on pushes to specified branches + branches: + - main + - development + - 'releases/*' # All branches under releases + +jobs: + plugin-check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + + - name: Run plugin check + uses: wordpress/plugin-check-action@v1.0.7 \ No newline at end of file diff --git a/README.md b/README.md index 53e9302..fe45ddc 100644 --- a/README.md +++ b/README.md @@ -1,111 +1,111 @@ -# Scouting Nederland Wordpress SOL Login -[![Wordpress-Supported](https://img.shields.io/wordpress/v/scouting-openid-connect.svg)](https://wordpress.org/plugins/scouting-openid-connect/) -[![Wordpress-Version](https://img.shields.io/wordpress/plugin/v/scouting-openid-connect.svg)](https://wordpress.org/plugins/scouting-openid-connect/) -[![Wordpress-Downloads](https://img.shields.io/wordpress/plugin/dt/scouting-openid-connect.svg)](https://wordpress.org/plugins/scouting-openid-connect/) -[![Wordpress-Active-Installs](https://img.shields.io/wordpress/plugin/installs/scouting-openid-connect.svg)](https://wordpress.org/plugins/scouting-openid-connect/) - -**Contributors:** [jobvk](https://github.com/jobvk) \ -**Requires at least:** 6.4.3 \ -**Tested up to:** 6.6.1 \ -**Stable tag:** 0.0.1 \ -**Tags:** scouting, scouting nederland, sol, openid connect, oidc \ -**License:** GPLv3 \ -**License URI:** https://www.gnu.org/licenses/gpl-3.0.html - -Connect your Wordpress website to the Scouting Nederland OpenID Connect server. - -## Index - -* [Description](#description) -* [Screenshots](#screenshots) -* [Installation](#installation) -* [Configuration](#configuration) -* [Shortcodes](#shortcodes) -* [Frequently-Asked-Questions](#frequently-asked-questions) -* [Upgrade-Notice](#upgrade-notice) -* [Translations](#translations) - -## Description - -This plugin allows users to authenticate and login to their WordPress websites using their Scouting Nederland OpenID Connect credentials. - -It provides a secure and convenient way for Scouting Nederland members to access their WordPress sites without the need for separate login credentials. - -With this plugin, users can seamlessly integrate their Scouting Nederland accounts with their WordPress websites, enhancing the user experience and simplifying the login process. - -Bugs and feature-requests can go to: [GitHub](https://github.com/Scouting-nl/OpenID-Connect-Wordpress/issues) or [WordPress](https://wordpress.org/support/plugin/scouting-openid-connect) - -## Screenshots - -### 1. wp-login.php with scouting-login - -![wp-login.php with scouting-login](assets/screenshot-1.png) - -### 2. Settings page - -![settings page](assets/screenshot-2.png) - -### 2. Support page - -![support page](assets/screenshot-3.png) - -## Installation - -1. Log in to your WordPress admin dashboard. -2. Navigate to Plugins > Add New. -3. In the search bar, type the name of the plugin you want to install. -4. Find the plugin in the search results and click Install Now. -5. After the plugin is installed, click Activate. - -## Configuration - -Make sure you have the role `webmaster` in [sol.scouting.nl](https://sol.scouting.nl). - -1. Go to [login.scouting.nl](https://login.scouting.nl), click on `Managed websites` and click on `Add OpenID Connect connection`. -2. Add the name of your group/website. -3. Add the Redirect URI, for example: https://example.com/. -4. Add the Post Logout Redirect URI, for example: https://example.com/. -5. Select the scopes you want to use. The `email` scope is required; the others are optional. -6. Select the organizations that can log in. \ - If your organization has sub-organizations, you can also select `Allow suborganizations.` -7. Press `Add Website.` -8. Find the website you just created and click on ⓘ. -9. Copy the `Client ID`, `Client Secret`, and the `Scopes` to your website. -10. Fill in the OpenID Connect Settings with the copied data. \ - Make sure the required scopes, `openid` and `email`, are present. -11. Fill in the General Settings. \ - If you want to store the name, birthdate, or gender, use the scope `profile`. \ - If you also want the SOL ID, use the scope `membership`. -12. Press `Save Settings`. -13. Log out and try to log in with the Scouts Login button. - -## Shortcodes - -### Link -This shortcode will create a login url - -`[scouting_oidc_link]` - -### button -This shortcode will create a login button - -`[scouting_oidc_button]` - -## Frequently Asked Questions - -### Do I need to be part of Scouting Nederland to use this? - -Yes, the OpenID Connect server is used to identify people and only allows access when they are members of the appropriate organization within Scouting Nederland. To set up the system at Scouting Nederland, you need webmaster privileges for your scouting group. - -### Are there settings for this plugin? - -Yes, there is a settings page where you can set up a redirect after login, configure the name the user gets in their profile, and enforce that. - -### Can roles also be imported into WordPress from SOL? - -Currently not, but this is planned for a future update of this plugin. - -## Translations - -* Dutch +# Scouting Nederland Wordpress SOL Login +[![Wordpress-Supported](https://img.shields.io/wordpress/v/scouting-openid-connect.svg)](https://wordpress.org/plugins/scouting-openid-connect/) +[![Wordpress-Version](https://img.shields.io/wordpress/plugin/v/scouting-openid-connect.svg)](https://wordpress.org/plugins/scouting-openid-connect/) +[![Wordpress-Downloads](https://img.shields.io/wordpress/plugin/dt/scouting-openid-connect.svg)](https://wordpress.org/plugins/scouting-openid-connect/) +[![Wordpress-Active-Installs](https://img.shields.io/wordpress/plugin/installs/scouting-openid-connect.svg)](https://wordpress.org/plugins/scouting-openid-connect/) + +**Contributors:** [jobvk](https://github.com/jobvk) \ +**Requires at least:** 6.4.3 \ +**Tested up to:** 6.6.1 \ +**Stable tag:** 0.0.1 \ +**Tags:** scouting, scouting nederland, sol, openid connect, oidc \ +**License:** GPLv3 \ +**License URI:** https://www.gnu.org/licenses/gpl-3.0.html + +Connect your Wordpress website to the Scouting Nederland OpenID Connect server. + +## Index + +* [Description](#description) +* [Screenshots](#screenshots) +* [Installation](#installation) +* [Configuration](#configuration) +* [Shortcodes](#shortcodes) +* [Frequently-Asked-Questions](#frequently-asked-questions) +* [Upgrade-Notice](#upgrade-notice) +* [Translations](#translations) + +## Description + +This plugin allows users to authenticate and login to their WordPress websites using their Scouting Nederland OpenID Connect credentials. + +It provides a secure and convenient way for Scouting Nederland members to access their WordPress sites without the need for separate login credentials. + +With this plugin, users can seamlessly integrate their Scouting Nederland accounts with their WordPress websites, enhancing the user experience and simplifying the login process. + +Bugs and feature-requests can go to: [GitHub](https://github.com/Scouting-nl/scouting-openid-connect/issues) or [WordPress](https://wordpress.org/support/plugin/scouting-openid-connect) + +## Screenshots + +### 1. wp-login.php with scouting-login + +![wp-login.php with scouting-login](assets/screenshot-1.png) + +### 2. Settings page + +![settings page](assets/screenshot-2.png) + +### 2. Support page + +![support page](assets/screenshot-3.png) + +## Installation + +1. Log in to your WordPress admin dashboard. +2. Navigate to Plugins > Add New. +3. In the search bar, type the name of the plugin you want to install. +4. Find the plugin in the search results and click Install Now. +5. After the plugin is installed, click Activate. + +## Configuration + +Make sure you have the role `webmaster` in [sol.scouting.nl](https://sol.scouting.nl). + +1. Go to [login.scouting.nl](https://login.scouting.nl), click on `Managed websites` and click on `Add OpenID Connect connection`. +2. Add the name of your group/website. +3. Add the Redirect URI, for example: https://example.com/. +4. Add the Post Logout Redirect URI, for example: https://example.com/. +5. Select the scopes you want to use. The `email` scope is required; the others are optional. +6. Select the organizations that can log in. \ + If your organization has sub-organizations, you can also select `Allow suborganizations.` +7. Press `Add Website.` +8. Find the website you just created and click on ⓘ. +9. Copy the `Client ID`, `Client Secret`, and the `Scopes` to your website. +10. Fill in the OpenID Connect Settings with the copied data. \ + Make sure the required scopes, `openid` and `email`, are present. +11. Fill in the General Settings. \ + If you want to store the name, birthdate, or gender, use the scope `profile`. \ + If you also want the SOL ID, use the scope `membership`. +12. Press `Save Settings`. +13. Log out and try to log in with the Scouts Login button. + +## Shortcodes + +### Link +This shortcode will create a login url + +`[scouting_oidc_link]` + +### button +This shortcode will create a login button + +`[scouting_oidc_button]` + +## Frequently Asked Questions + +### Do I need to be part of Scouting Nederland to use this? + +Yes, the OpenID Connect server is used to identify people and only allows access when they are members of the appropriate organization within Scouting Nederland. To set up the system at Scouting Nederland, you need webmaster privileges for your scouting group. + +### Are there settings for this plugin? + +Yes, there is a settings page where you can set up a redirect after login, configure the name the user gets in their profile, and enforce that. + +### Can roles also be imported into WordPress from SOL? + +Currently not, but this is planned for a future update of this plugin. + +## Translations + +* Dutch * English \ No newline at end of file diff --git a/assets/screenshot-3-en.png b/assets/screenshot-3-en.png index cfaf743..79a7aff 100644 Binary files a/assets/screenshot-3-en.png and b/assets/screenshot-3-en.png differ diff --git a/assets/screenshot-3-nl.png b/assets/screenshot-3-nl.png index f253186..13d7495 100644 Binary files a/assets/screenshot-3-nl.png and b/assets/screenshot-3-nl.png differ diff --git a/assets/screenshot-3.png b/assets/screenshot-3.png index cfaf743..79a7aff 100644 Binary files a/assets/screenshot-3.png and b/assets/screenshot-3.png differ diff --git a/assets/screenshot-4-en.png b/assets/screenshot-4-en.png new file mode 100644 index 0000000..cb80a3e Binary files /dev/null and b/assets/screenshot-4-en.png differ diff --git a/assets/screenshot-4-nl.png b/assets/screenshot-4-nl.png new file mode 100644 index 0000000..d594db7 Binary files /dev/null and b/assets/screenshot-4-nl.png differ diff --git a/assets/screenshot-4.png b/assets/screenshot-4.png new file mode 100644 index 0000000..cb80a3e Binary files /dev/null and b/assets/screenshot-4.png differ diff --git a/languages/scouting-openid-connect-nl_NL.mo b/languages/scouting-openid-connect-nl_NL.mo index 94edcef..0c31625 100644 Binary files a/languages/scouting-openid-connect-nl_NL.mo and b/languages/scouting-openid-connect-nl_NL.mo differ diff --git a/languages/scouting-openid-connect-nl_NL.po b/languages/scouting-openid-connect-nl_NL.po index 94c3d81..0b3fbe9 100644 --- a/languages/scouting-openid-connect-nl_NL.po +++ b/languages/scouting-openid-connect-nl_NL.po @@ -5,8 +5,8 @@ msgstr "" "Project-Id-Version: Scouting OpenID Connect 0.0.1\n" "Report-Msgid-Bugs-To: https://github.com/jobvk/scouting-openid-connect/" "issues\n" -"POT-Creation-Date: 2024-10-30 23:50+0100\n" -"PO-Revision-Date: 2024-10-30 23:50+0100\n" +"POT-Creation-Date: 2024-11-04 21:19+0100\n" +"PO-Revision-Date: 2024-11-04 21:19+0100\n" "Last-Translator: Job van Koeveringe \n" "Language-Team: Job van Koeveringe \n" "Language: nl_NL\n" @@ -187,22 +187,22 @@ msgstr "Achternaam" msgid "Username" msgstr "Gebruikersnaam" -#: settings/general.php:183 +#: settings/general.php:182 msgid "" "This prefix will be added to the username of all Scouting Nederland users" msgstr "" "Dit voorvoegsel wordt toegevoegd aan de gebruikersnaam van alle Scouting " "Nederland gebruikers" -#: settings/general.php:189 +#: settings/general.php:188 msgid "Default (no action)" msgstr "Standaard (geen actie)" -#: settings/general.php:190 +#: settings/general.php:189 msgid "Frontpage" msgstr "Voorpagina" -#: settings/general.php:191 +#: settings/general.php:190 msgid "Dashboard" msgstr "Dashboard" diff --git a/languages/scouting-openid-connect.pot b/languages/scouting-openid-connect.pot index d641d1e..7b8a2e1 100644 --- a/languages/scouting-openid-connect.pot +++ b/languages/scouting-openid-connect.pot @@ -1,467 +1,467 @@ -# Copyright (C) 2024 Scouting Nederland -# This file is distributed under the same license as the Scouting OpenID Connect plugin. -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: Scouting OpenID Connect 0.0.1\n" -"Report-Msgid-Bugs-To: https://github.com/jobvk/scouting-openid-connect/issues\n" -"POT-Creation-Date: 2024-10-30 23:46+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: Job van Koeveringe \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.5\n" -"X-Poedit-KeywordsList: __;esc_html__;_e;esc_html_e\n" -"X-Poedit-Basepath: ../src\n" -"X-Poedit-SourceCharset: UTF-8\n" -"X-Poedit-SearchPath-0: .\n" - -#: auth/OpenIDConnectClient.php:101 -msgid "The authorization endpoint is not available in the well known data." -msgstr "" - -#: auth/OpenIDConnectClient.php:135 -msgid "The token endpoint is not available in the well known data." -msgstr "" - -#: auth/OpenIDConnectClient.php:167 -msgid "Failed to retrieve tokens. Response code:" -msgstr "" - -#: auth/OpenIDConnectClient.php:167 auth/OpenIDConnectClient.php:267 -msgid "Response message:" -msgstr "" - -#: auth/OpenIDConnectClient.php:193 -msgid "The ID token is not available in the tokens." -msgstr "" - -#: auth/OpenIDConnectClient.php:198 -msgid "The JSON Web Key Set (JWKS) is not available" -msgstr "" - -#: auth/OpenIDConnectClient.php:220 -msgid "The certificate chain (x5c) for the key ID (kid) specified in the header was not found." -msgstr "" - -#: auth/OpenIDConnectClient.php:230 -msgid "The signature in the ID token is not valid." -msgstr "" - -#: auth/OpenIDConnectClient.php:245 -msgid "The userinfo endpoint is not available in the well known data." -msgstr "" - -#: auth/OpenIDConnectClient.php:250 -msgid "The access token is not available in the tokens." -msgstr "" - -#: auth/OpenIDConnectClient.php:267 -msgid "Failed to retrieve user info. Response code:" -msgstr "" - -#: auth/OpenIDConnectClient.php:281 -msgid "The end session endpoint is not available in the well known data." -msgstr "" - -#: auth/OpenIDConnectClient.php:306 -msgid "An issuer must be provided in the config." -msgstr "" - -#: auth/OpenIDConnectClient.php:311 -msgid "The issuer URL is not valid." -msgstr "" - -#: auth/OpenIDConnectClient.php:334 -msgid "Scopes must be a non-empty array." -msgstr "" - -#: auth/OpenIDConnectClient.php:341 -msgid "Scope" -msgstr "" - -#: auth/OpenIDConnectClient.php:341 -msgid "is not supported by the server, supported scopes are:" -msgstr "" - -#: auth/OpenIDConnectClient.php:358 -msgid "Well known data is not available." -msgstr "" - -#: auth/OpenIDConnectClient.php:363 -msgid "The jwks_uri is not available in the well known data." -msgstr "" - -#: auth/OpenIDConnectClient.php:368 -msgid "The jwks_uri is not a valid URL." -msgstr "" - -#: auth/auth.php:39 auth/auth.php:72 -msgid "Login with Scouts Online" -msgstr "" - -#: auth/auth.php:99 -msgid "Nonce is invalid" -msgstr "" - -#: auth/auth.php:128 -msgid "State is invalid" -msgstr "" - -#: auth/auth.php:139 -msgid "Code is missing" -msgstr "" - -#: auth/auth.php:164 -msgid "Webmaster disabled creation of new accounts" -msgstr "" - -#: auth/auth.php:196 -msgid "The user denied the request" -msgstr "" - -#: plugin/actions.php:15 settings/page.php:30 -msgid "Settings" -msgstr "" - -#: plugin/description.php:16 -msgid "WordPress plugin for logging in with Scouting Nederland OpenID Connect Server." -msgstr "" - -#: settings/general.php:12 -msgid "General Settings" -msgstr "" - -#: settings/general.php:20 -msgid "Set display name" -msgstr "" - -#: settings/general.php:29 -msgid "Store birthdate to local profile" -msgstr "" - -#: settings/general.php:38 -msgid "Store gender to local profile" -msgstr "" - -#: settings/general.php:47 -msgid "Store Scouting ID to local profile" -msgstr "" - -#: settings/general.php:56 -msgid "Allow new user accounts" -msgstr "" - -#: settings/general.php:65 -msgid "Prefix for all Scouting Nederland users" -msgstr "" - -#: settings/general.php:74 -msgid "After a successful login redirect user to" -msgstr "" - -#: settings/general.php:129 -msgid "Full name" -msgstr "" - -#: settings/general.php:130 -msgid "First name" -msgstr "" - -#: settings/general.php:131 -msgid "Last name" -msgstr "" - -#: settings/general.php:132 -msgid "Username" -msgstr "" - -#: settings/general.php:183 -msgid "This prefix will be added to the username of all Scouting Nederland users" -msgstr "" - -#: settings/general.php:189 -msgid "Default (no action)" -msgstr "" - -#: settings/general.php:190 -msgid "Frontpage" -msgstr "" - -#: settings/general.php:191 -msgid "Dashboard" -msgstr "" - -#: settings/oidc.php:12 -msgid "OpenID Connect Settings" -msgstr "" - -#: settings/oidc.php:20 -msgid "Client ID" -msgstr "" - -#: settings/oidc.php:29 -msgid "Client Secret" -msgstr "" - -#: settings/oidc.php:38 -msgid "Scopes" -msgstr "" - -#: settings/page.php:32 -msgid "Need help with setting up?" -msgstr "" - -#: settings/page.php:33 -msgid "Go to the support page" -msgstr "" - -#: shortcode/page.php:24 -msgid "Shortcode" -msgstr "" - -#: shortcode/page.php:27 -msgid "Shortcodes are small pieces of code that allow you to easily add dynamic content to your WordPress site, enabling you to embed files or create objects with just one line of code." -msgstr "" - -#: shortcode/page.php:29 -msgid "They can be used for various purposes, such as adding galleries, embedding videos, or displaying specific content types." -msgstr "" - -#: shortcode/page.php:31 -msgid "To use a shortcode, simply insert it into the content area of your post or page, and WordPress will parse it, replacing it with the corresponding content when viewed." -msgstr "" - -#: shortcode/page.php:33 -msgid "For more information on how to use shortcodes and their benefits, visit the following link: " -msgstr "" - -#: shortcode/page.php:34 -msgid "WordPress Shortcode Block Support" -msgstr "" - -#: shortcode/page.php:37 -msgid "Shortcodes for OpenID Connect" -msgstr "" - -#: shortcode/page.php:39 -msgid "OpenID Connect Button" -msgstr "" - -#: shortcode/page.php:42 -msgid "Button Example" -msgstr "" - -#: shortcode/page.php:44 -msgid "The OpenID Connect button shortcode allows you to add a button to your WordPress site that users can click to log in using their Scouts Online account." -msgstr "" - -#: shortcode/page.php:46 -msgid "To add the OpenID Connect button to your site, use the following shortcode:" -msgstr "" - -#: shortcode/page.php:49 -msgid "You can customize the appearance of the button by adding attributes to the shortcode. The following attributes are available:" -msgstr "" - -#: shortcode/page.php:51 -msgid "The width of the button in pixels." -msgstr "" - -#: shortcode/page.php:52 -msgid "The height of the button in pixels." -msgstr "" - -#: shortcode/page.php:53 -msgid "The background color of the button." -msgstr "" - -#: shortcode/page.php:54 -msgid "The text color of the button." -msgstr "" - -#: shortcode/page.php:58 -msgid "Live Shortcode Editor" -msgstr "" - -#: shortcode/page.php:62 -msgid "Default is 250px, minimum is 120px. If the width is smaller than 225px, the logo will be removed." -msgstr "" - -#: shortcode/page.php:66 -msgid "Default is 40px, minimum is 40px." -msgstr "" - -#: shortcode/page.php:70 -msgid "The default color is #4caf50." -msgstr "" - -#: shortcode/page.php:74 -msgid "The default color is #ffffff." -msgstr "" - -#: shortcode/page.php:80 -msgid "Example of the shortcode with custom attributes:" -msgstr "" - -#: shortcode/page.php:82 -msgid "Example of the shortcode above:" -msgstr "" - -#: shortcode/page.php:84 -msgid "Note: The button is not interactive in this preview." -msgstr "" - -#: shortcode/page.php:89 -msgid "OpenID Connect Link" -msgstr "" - -#: shortcode/page.php:91 -msgid "The OpenID Connect link shortcode allows you to add a text link to your WordPress site that users can click to log in using their Scouts Online account." -msgstr "" - -#: shortcode/page.php:93 -msgid "To add the OpenID Connect link to your site, use the following shortcode:" -msgstr "" - -#: shortcode/page.php:96 -msgid "You can not customize the appearance of the link." -msgstr "" - -#: shortcode/page.php:97 -msgid "Example of the link shortcode:" -msgstr "" - -#: shortcode/page.php:98 -msgid "Note: Do not copy this link, it will not work. This is just an example of how the link will look like." -msgstr "" - -#: support/page.php:24 support/page.php:49 -msgid "Support" -msgstr "" - -#: support/page.php:25 -msgid "Before you start make sure you have the role \"webmaster\" in" -msgstr "" - -#: support/page.php:29 -msgid "Setting up OpenID Connect" -msgstr "" - -#: support/page.php:31 -msgid "Go to" -msgstr "" - -#: support/page.php:31 -msgid "click on \"Managed websites\" and click on \"Add OpenID Connect connection\"." -msgstr "" - -#: support/page.php:32 -msgid "Add the name of your group/website." -msgstr "" - -#: support/page.php:33 -msgid "Add the Redirect URI:" -msgstr "" - -#: support/page.php:34 -msgid "Add the Post Logout Redirect URI:" -msgstr "" - -#: support/page.php:35 -msgid "Select the scopes you want to use. The \"email\" scope is required; the \"profile\" and \"membership\" scopes are optional." -msgstr "" - -#: support/page.php:36 -msgid "Select the organizations that can log in." -msgstr "" - -#: support/page.php:37 -msgid "If your organization has sub-organizations, you can also select \"Allow suborganizations.\"" -msgstr "" - -#: support/page.php:38 -msgid "Press \"Add Website.\"" -msgstr "" - -#: support/page.php:39 -msgid "Find the website you just created and click on ⓘ." -msgstr "" - -#: support/page.php:40 -msgid "Copy the \"Client ID\", \"Client Secret\", and the \"Scopes\" to the" -msgstr "" - -#: support/page.php:43 -msgid "Fill in the OpenID Connect Settings with the copied data. Make sure the required scopes, \"openid\" and \"email\", are present." -msgstr "" - -#: support/page.php:44 -msgid "Fill in the General Settings. If you want to store the name, birthdate, or gender, use the scope \"profile\". If you also want the SOL ID, use the scope \"membership\"." -msgstr "" - -#: support/page.php:45 -msgid "Press \"Save Settings\"" -msgstr "" - -#: support/page.php:46 -msgid "Log out and try to log in with the Scouts Login button." -msgstr "" - -#: support/page.php:50 -msgid "If you need help, please contact" -msgstr "" - -#: support/page.php:52 -msgid "(developer of the plugin)" -msgstr "" - -#: user/fields.php:15 -msgid "Scouts Online (SOL) Profile Information" -msgstr "" - -#: user/fields.php:41 -msgid "Scouting ID" -msgstr "" - -#: user/fields.php:57 -msgid "Birthdate" -msgstr "" - -#: user/fields.php:73 -msgid "Gender" -msgstr "" - -#: user/fields.php:76 -msgid "Male" -msgstr "" - -#: user/fields.php:77 -msgid "Female" -msgstr "" - -#: user/fields.php:78 -msgid "Other" -msgstr "" - -#: user/fields.php:79 -msgid "Unknown" -msgstr "" - -#: user/fields.php:95 -msgid "Infix" -msgstr "" - -#: user/user.php:74 -msgid "Email scope is missing" -msgstr "" - -#: user/user.php:175 -msgid "Username and Email have different user ID" -msgstr "" - -#: user/user.php:203 -msgid "Something went wrong while trying to log in" -msgstr "" +# Copyright (C) 2024 Scouting Nederland +# This file is distributed under the same license as the Scouting OpenID Connect plugin. +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Scouting OpenID Connect 0.0.1\n" +"Report-Msgid-Bugs-To: https://github.com/jobvk/scouting-openid-connect/issues\n" +"POT-Creation-Date: 2024-11-04 21:19+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Job van Koeveringe \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.5\n" +"X-Poedit-KeywordsList: __;esc_html__;_e;esc_html_e\n" +"X-Poedit-Basepath: ../src\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-SearchPath-0: .\n" + +#: auth/OpenIDConnectClient.php:101 +msgid "The authorization endpoint is not available in the well known data." +msgstr "" + +#: auth/OpenIDConnectClient.php:135 +msgid "The token endpoint is not available in the well known data." +msgstr "" + +#: auth/OpenIDConnectClient.php:167 +msgid "Failed to retrieve tokens. Response code:" +msgstr "" + +#: auth/OpenIDConnectClient.php:167 auth/OpenIDConnectClient.php:267 +msgid "Response message:" +msgstr "" + +#: auth/OpenIDConnectClient.php:193 +msgid "The ID token is not available in the tokens." +msgstr "" + +#: auth/OpenIDConnectClient.php:198 +msgid "The JSON Web Key Set (JWKS) is not available" +msgstr "" + +#: auth/OpenIDConnectClient.php:220 +msgid "The certificate chain (x5c) for the key ID (kid) specified in the header was not found." +msgstr "" + +#: auth/OpenIDConnectClient.php:230 +msgid "The signature in the ID token is not valid." +msgstr "" + +#: auth/OpenIDConnectClient.php:245 +msgid "The userinfo endpoint is not available in the well known data." +msgstr "" + +#: auth/OpenIDConnectClient.php:250 +msgid "The access token is not available in the tokens." +msgstr "" + +#: auth/OpenIDConnectClient.php:267 +msgid "Failed to retrieve user info. Response code:" +msgstr "" + +#: auth/OpenIDConnectClient.php:281 +msgid "The end session endpoint is not available in the well known data." +msgstr "" + +#: auth/OpenIDConnectClient.php:306 +msgid "An issuer must be provided in the config." +msgstr "" + +#: auth/OpenIDConnectClient.php:311 +msgid "The issuer URL is not valid." +msgstr "" + +#: auth/OpenIDConnectClient.php:334 +msgid "Scopes must be a non-empty array." +msgstr "" + +#: auth/OpenIDConnectClient.php:341 +msgid "Scope" +msgstr "" + +#: auth/OpenIDConnectClient.php:341 +msgid "is not supported by the server, supported scopes are:" +msgstr "" + +#: auth/OpenIDConnectClient.php:358 +msgid "Well known data is not available." +msgstr "" + +#: auth/OpenIDConnectClient.php:363 +msgid "The jwks_uri is not available in the well known data." +msgstr "" + +#: auth/OpenIDConnectClient.php:368 +msgid "The jwks_uri is not a valid URL." +msgstr "" + +#: auth/auth.php:39 auth/auth.php:72 +msgid "Login with Scouts Online" +msgstr "" + +#: auth/auth.php:99 +msgid "Nonce is invalid" +msgstr "" + +#: auth/auth.php:128 +msgid "State is invalid" +msgstr "" + +#: auth/auth.php:139 +msgid "Code is missing" +msgstr "" + +#: auth/auth.php:164 +msgid "Webmaster disabled creation of new accounts" +msgstr "" + +#: auth/auth.php:196 +msgid "The user denied the request" +msgstr "" + +#: plugin/actions.php:15 settings/page.php:30 +msgid "Settings" +msgstr "" + +#: plugin/description.php:16 +msgid "WordPress plugin for logging in with Scouting Nederland OpenID Connect Server." +msgstr "" + +#: settings/general.php:12 +msgid "General Settings" +msgstr "" + +#: settings/general.php:20 +msgid "Set display name" +msgstr "" + +#: settings/general.php:29 +msgid "Store birthdate to local profile" +msgstr "" + +#: settings/general.php:38 +msgid "Store gender to local profile" +msgstr "" + +#: settings/general.php:47 +msgid "Store Scouting ID to local profile" +msgstr "" + +#: settings/general.php:56 +msgid "Allow new user accounts" +msgstr "" + +#: settings/general.php:65 +msgid "Prefix for all Scouting Nederland users" +msgstr "" + +#: settings/general.php:74 +msgid "After a successful login redirect user to" +msgstr "" + +#: settings/general.php:129 +msgid "Full name" +msgstr "" + +#: settings/general.php:130 +msgid "First name" +msgstr "" + +#: settings/general.php:131 +msgid "Last name" +msgstr "" + +#: settings/general.php:132 +msgid "Username" +msgstr "" + +#: settings/general.php:182 +msgid "This prefix will be added to the username of all Scouting Nederland users" +msgstr "" + +#: settings/general.php:188 +msgid "Default (no action)" +msgstr "" + +#: settings/general.php:189 +msgid "Frontpage" +msgstr "" + +#: settings/general.php:190 +msgid "Dashboard" +msgstr "" + +#: settings/oidc.php:12 +msgid "OpenID Connect Settings" +msgstr "" + +#: settings/oidc.php:20 +msgid "Client ID" +msgstr "" + +#: settings/oidc.php:29 +msgid "Client Secret" +msgstr "" + +#: settings/oidc.php:38 +msgid "Scopes" +msgstr "" + +#: settings/page.php:32 +msgid "Need help with setting up?" +msgstr "" + +#: settings/page.php:33 +msgid "Go to the support page" +msgstr "" + +#: shortcode/page.php:24 +msgid "Shortcode" +msgstr "" + +#: shortcode/page.php:27 +msgid "Shortcodes are small pieces of code that allow you to easily add dynamic content to your WordPress site, enabling you to embed files or create objects with just one line of code." +msgstr "" + +#: shortcode/page.php:29 +msgid "They can be used for various purposes, such as adding galleries, embedding videos, or displaying specific content types." +msgstr "" + +#: shortcode/page.php:31 +msgid "To use a shortcode, simply insert it into the content area of your post or page, and WordPress will parse it, replacing it with the corresponding content when viewed." +msgstr "" + +#: shortcode/page.php:33 +msgid "For more information on how to use shortcodes and their benefits, visit the following link: " +msgstr "" + +#: shortcode/page.php:34 +msgid "WordPress Shortcode Block Support" +msgstr "" + +#: shortcode/page.php:37 +msgid "Shortcodes for OpenID Connect" +msgstr "" + +#: shortcode/page.php:39 +msgid "OpenID Connect Button" +msgstr "" + +#: shortcode/page.php:42 +msgid "Button Example" +msgstr "" + +#: shortcode/page.php:44 +msgid "The OpenID Connect button shortcode allows you to add a button to your WordPress site that users can click to log in using their Scouts Online account." +msgstr "" + +#: shortcode/page.php:46 +msgid "To add the OpenID Connect button to your site, use the following shortcode:" +msgstr "" + +#: shortcode/page.php:49 +msgid "You can customize the appearance of the button by adding attributes to the shortcode. The following attributes are available:" +msgstr "" + +#: shortcode/page.php:51 +msgid "The width of the button in pixels." +msgstr "" + +#: shortcode/page.php:52 +msgid "The height of the button in pixels." +msgstr "" + +#: shortcode/page.php:53 +msgid "The background color of the button." +msgstr "" + +#: shortcode/page.php:54 +msgid "The text color of the button." +msgstr "" + +#: shortcode/page.php:58 +msgid "Live Shortcode Editor" +msgstr "" + +#: shortcode/page.php:62 +msgid "Default is 250px, minimum is 120px. If the width is smaller than 225px, the logo will be removed." +msgstr "" + +#: shortcode/page.php:66 +msgid "Default is 40px, minimum is 40px." +msgstr "" + +#: shortcode/page.php:70 +msgid "The default color is #4caf50." +msgstr "" + +#: shortcode/page.php:74 +msgid "The default color is #ffffff." +msgstr "" + +#: shortcode/page.php:80 +msgid "Example of the shortcode with custom attributes:" +msgstr "" + +#: shortcode/page.php:82 +msgid "Example of the shortcode above:" +msgstr "" + +#: shortcode/page.php:84 +msgid "Note: The button is not interactive in this preview." +msgstr "" + +#: shortcode/page.php:89 +msgid "OpenID Connect Link" +msgstr "" + +#: shortcode/page.php:91 +msgid "The OpenID Connect link shortcode allows you to add a text link to your WordPress site that users can click to log in using their Scouts Online account." +msgstr "" + +#: shortcode/page.php:93 +msgid "To add the OpenID Connect link to your site, use the following shortcode:" +msgstr "" + +#: shortcode/page.php:96 +msgid "You can not customize the appearance of the link." +msgstr "" + +#: shortcode/page.php:97 +msgid "Example of the link shortcode:" +msgstr "" + +#: shortcode/page.php:98 +msgid "Note: Do not copy this link, it will not work. This is just an example of how the link will look like." +msgstr "" + +#: support/page.php:24 support/page.php:49 +msgid "Support" +msgstr "" + +#: support/page.php:25 +msgid "Before you start make sure you have the role \"webmaster\" in" +msgstr "" + +#: support/page.php:29 +msgid "Setting up OpenID Connect" +msgstr "" + +#: support/page.php:31 +msgid "Go to" +msgstr "" + +#: support/page.php:31 +msgid "click on \"Managed websites\" and click on \"Add OpenID Connect connection\"." +msgstr "" + +#: support/page.php:32 +msgid "Add the name of your group/website." +msgstr "" + +#: support/page.php:33 +msgid "Add the Redirect URI:" +msgstr "" + +#: support/page.php:34 +msgid "Add the Post Logout Redirect URI:" +msgstr "" + +#: support/page.php:35 +msgid "Select the scopes you want to use. The \"email\" scope is required; the \"profile\" and \"membership\" scopes are optional." +msgstr "" + +#: support/page.php:36 +msgid "Select the organizations that can log in." +msgstr "" + +#: support/page.php:37 +msgid "If your organization has sub-organizations, you can also select \"Allow suborganizations.\"" +msgstr "" + +#: support/page.php:38 +msgid "Press \"Add Website.\"" +msgstr "" + +#: support/page.php:39 +msgid "Find the website you just created and click on ⓘ." +msgstr "" + +#: support/page.php:40 +msgid "Copy the \"Client ID\", \"Client Secret\", and the \"Scopes\" to the" +msgstr "" + +#: support/page.php:43 +msgid "Fill in the OpenID Connect Settings with the copied data. Make sure the required scopes, \"openid\" and \"email\", are present." +msgstr "" + +#: support/page.php:44 +msgid "Fill in the General Settings. If you want to store the name, birthdate, or gender, use the scope \"profile\". If you also want the SOL ID, use the scope \"membership\"." +msgstr "" + +#: support/page.php:45 +msgid "Press \"Save Settings\"" +msgstr "" + +#: support/page.php:46 +msgid "Log out and try to log in with the Scouts Login button." +msgstr "" + +#: support/page.php:50 +msgid "If you need help, please contact" +msgstr "" + +#: support/page.php:52 +msgid "(developer of the plugin)" +msgstr "" + +#: user/fields.php:15 +msgid "Scouts Online (SOL) Profile Information" +msgstr "" + +#: user/fields.php:41 +msgid "Scouting ID" +msgstr "" + +#: user/fields.php:57 +msgid "Birthdate" +msgstr "" + +#: user/fields.php:73 +msgid "Gender" +msgstr "" + +#: user/fields.php:76 +msgid "Male" +msgstr "" + +#: user/fields.php:77 +msgid "Female" +msgstr "" + +#: user/fields.php:78 +msgid "Other" +msgstr "" + +#: user/fields.php:79 +msgid "Unknown" +msgstr "" + +#: user/fields.php:95 +msgid "Infix" +msgstr "" + +#: user/user.php:74 +msgid "Email scope is missing" +msgstr "" + +#: user/user.php:175 +msgid "Username and Email have different user ID" +msgstr "" + +#: user/user.php:203 +msgid "Something went wrong while trying to log in" +msgstr "" diff --git a/readme.txt b/readme.txt index 771028e..b8ed133 100644 --- a/readme.txt +++ b/readme.txt @@ -1,66 +1,67 @@ -=== Scouting OpenID Connect === -Contributors: jobvk -Tags: scouting, scouting nederland, sol, openid connect, oidc -Requires at least: 6.4.3 -Tested up to: 6.6.2 -Stable tag: 0.0.1 -Requires PHP: 8.2 -License: GPLv3 -License URI: https://www.gnu.org/licenses/gpl-3.0.html - -WordPress plugin for logging in with Scouting Nederland OpenID Connect Server. - -== Description == - -A WordPress plugin for logging in with Scouting Nederland OpenID Connect Server. - -This plugin allows users to authenticate and login to their WordPress websites using their Scouting Nederland OpenID Connect credentials. -It provides a secure and convenient way for Scouting Nederland members to access their WordPress sites without the need for separate login credentials. -With this plugin, users can seamlessly integrate their Scouting Nederland accounts with their WordPress websites, enhancing the user experience and simplifying the login process. - -== Installation == - -1. Go to https://login.scouting.nl, click on "Managed websites" and click on "Add OpenID Connect connection". -2. Add the name of your group/website. -3. Add the Redirect URI, for example: https://example.com/. -4. Add the Post Logout Redirect URI, for example: https://example.com/. -5. Select the scopes you want to use. The "email" scope is required; the "profile" and "membership" scopes are optional. -6. Select the organizations that can log in. If your organization has sub-organizations, you can also select `Allow suborganizations.` -7. Press `Add Website.` -8. Find the website you just created and click on ⓘ. -9. Copy the `Client ID`, `Client Secret`, and the `Scopes` to your website. -10. Fill in the OpenID Connect Settings with the copied data. Make sure the required scopes, "openid" and "email", are present. -11. Fill in the General Settings. If you want to store the name, birthdate, or gender, use the scope "profile". If you also want the SOL ID, use the scope "membership". -12. Press "Save Settings." -13. Log out and try to log in with the Scouts Login button. - -== Frequently Asked Questions == - -= Do i need to be part of Scouting Nederland to use this? = - -Yes, the OpenID Connect server is used to identify people and only allows access when they are members of the appropriate organization within Scouting Nederland. -To set up the system at Scouting Nederland, you need webmaster privileges for your scouting group. - -= Are there settings for this plugin? = - -Yes, there is a settings page where you can set up a redirect after login or logout, configure the name the user gets in their profile, and enforce that. - -= Can roles also be imported into WordPress from SOL? = - -Currently not, but this is planned for a future update of this plugin. - -== Screenshots == - -1. Login Page -2. Settings Page -3. Support Page - -== Changelog == - -= 0.0.1 = -Initial release - -== Upgrade Notice == - -= 0.0.1 = +=== Scouting OpenID Connect === +Contributors: jobvk +Tags: scouting, scouting nederland, sol, openid connect, oidc +Requires at least: 6.4.3 +Tested up to: 6.6.2 +Stable tag: 0.0.1 +Requires PHP: 8.2 +License: GPLv3 +License URI: https://www.gnu.org/licenses/gpl-3.0.html + +WordPress plugin for logging in with Scouting Nederland OpenID Connect Server. + +== Description == + +A WordPress plugin for logging in with Scouting Nederland OpenID Connect Server. + +This plugin allows users to authenticate and login to their WordPress websites using their Scouting Nederland OpenID Connect credentials. +It provides a secure and convenient way for Scouting Nederland members to access their WordPress sites without the need for separate login credentials. +With this plugin, users can seamlessly integrate their Scouting Nederland accounts with their WordPress websites, enhancing the user experience and simplifying the login process. + +== Installation == + +1. Go to https://login.scouting.nl, click on "Managed websites" and click on "Add OpenID Connect connection". +2. Add the name of your group/website. +3. Add the Redirect URI, for example: https://example.com/. +4. Add the Post Logout Redirect URI, for example: https://example.com/. +5. Select the scopes you want to use. The "email" scope is required; the "profile" and "membership" scopes are optional. +6. Select the organizations that can log in. If your organization has sub-organizations, you can also select `Allow suborganizations.` +7. Press `Add Website.` +8. Find the website you just created and click on ⓘ. +9. Copy the `Client ID`, `Client Secret`, and the `Scopes` to your website. +10. Fill in the OpenID Connect Settings with the copied data. Make sure the required scopes, "openid" and "email", are present. +11. Fill in the General Settings. If you want to store the name, birthdate, or gender, use the scope "profile". If you also want the SOL ID, use the scope "membership". +12. Press "Save Settings." +13. Log out and try to log in with the Scouts Login button. + +== Frequently Asked Questions == + += Do i need to be part of Scouting Nederland to use this? = + +Yes, the OpenID Connect server is used to identify people and only allows access when they are members of the appropriate organization within Scouting Nederland. +To set up the system at Scouting Nederland, you need webmaster privileges for your scouting group. + += Are there settings for this plugin? = + +Yes, there is a settings page where you can set up a redirect after login or logout, configure the name the user gets in their profile, and enforce that. + += Can roles also be imported into WordPress from SOL? = + +Currently not, but this is planned for a future update of this plugin. + +== Screenshots == + +1. Login Page +2. Settings Page +3. Shortcode Page +4. Support Page + +== Changelog == + += 0.0.1 = +Initial release + +== Upgrade Notice == + += 0.0.1 = Initial release \ No newline at end of file diff --git a/scouting-openid-connect.php b/scouting-openid-connect.php index 71a72b4..12ee729 100644 --- a/scouting-openid-connect.php +++ b/scouting-openid-connect.php @@ -1,128 +1,130 @@ - - * @copyright 2024 Scouting Nederland - * @license GPLv3 - * @version 0.0.1 - * @link https://github.com/Scouting-nl/OpenID-Connect-Wordpress - * - * @wordpress-plugin - * Plugin Name: Scouting OpenID Connect - * Plugin URI: https://github.com/Scouting-nl/OpenID-Connect-Wordpress - * Description: WordPress plugin for logging in with Scouting Nederland OpenID Connect Server. - * Version: 0.0.1 - * Requires at least: 6.4.3 - * Requires PHP: 8.2 - * Author: Job van Koeveringe - * Author URI: https://jobvankoeveringe.com?utm_source=wordpress&utm_medium=plugin&utm_campaign=scouting_oidc - * License: GPLv3 - * License URI: https://www.gnu.org/licenses/gpl-3.0.html - * Text Domain: scouting-openid-connect - * Domain Path: /languages - **/ - -require_once 'src/auth/auth.php'; -require_once 'src/auth/session.php'; -require_once 'src/menu/menu.php'; -require_once 'src/settings/page.php'; -require_once 'src/shortcode/page.php'; -require_once 'src/support/page.php'; -include_once 'src/plugin/actions.php'; -include_once 'src/plugin/description.php'; -include_once 'src/user/fields.php'; - -use ScoutingOIDC\Auth; -use ScoutingOIDC\Session; -use ScoutingOIDC\Menu; -use ScoutingOIDC\Actions; -use ScoutingOIDC\Description; -use ScoutingOIDC\Settings; -use ScoutingOIDC\Shortcode; -use ScoutingOIDC\Support; -use ScoutingOIDC\Fields; - -$scouting_oidc_auth = new Auth(); -$scouting_oidc_session = new Session(); -$scouting_oidc_menu = new Menu(); -$scouting_oidc_actions = new Actions(); -$scouting_oidc_description = new Description(); -$scouting_oidc_settings = new Settings(); -$scouting_oidc_shortcode = new Shortcode(); -$scouting_oidc_support = new Support(); -$scouting_oidc_fields = new Fields(); - -// Init plugin -function scouting_oidc_init() -{ - // Add translations to the plugin - load_plugin_textdomain('scouting-openid-connect', false, dirname(plugin_basename(__FILE__)) . '/languages'); - - // Add the OpenID Connect button to the login form - add_action('login_form', array($GLOBALS['scouting_oidc_auth'], 'scouting_oidc_auth_login_form')); - - // Create shortcodes for OpenID Connect button and link - add_shortcode('scouting_oidc_button', array($GLOBALS['scouting_oidc_auth'], 'scouting_oidc_auth_login_button_shortcode')); - add_shortcode('scouting_oidc_link', array($GLOBALS['scouting_oidc_auth'], 'scouting_oidc_auth_login_url_shortcode')); - - // Geef extra links in de plugin-overzichtspagina - add_filter('plugin_action_links_'.plugin_basename(__FILE__), [$GLOBALS['scouting_oidc_actions'], 'scouting_oidc_actions_plugin_links']); - - // Add scouting ID, birthday and gender to user profile - if (get_option('scouting_oidc_user_scouting_id') || get_option('scouting_oidc_user_birthday') || get_option('scouting_oidc_user_gender')) - { - add_action('show_user_profile', [$GLOBALS['scouting_oidc_fields'], 'scouting_oidc_fields_user_profile']); - add_action('edit_user_profile', [$GLOBALS['scouting_oidc_fields'], 'scouting_oidc_fields_user_profile']); - } - - // Add infix field to user profile - add_action('show_user_profile', [$GLOBALS['scouting_oidc_fields'], 'scouting_oidc_fields_show_infix_field']); - add_action('edit_user_profile', [$GLOBALS['scouting_oidc_fields'], 'scouting_oidc_fields_show_infix_field']); - add_action('admin_enqueue_scripts', [$GLOBALS['scouting_oidc_fields'], 'scouting_oidc_fields_enqueue_infix_field_script']); - add_action('admin_enqueue_scripts', [$GLOBALS['scouting_oidc_shortcode'], 'scouting_oidc_shortcode_enqueue_live_script']); -} -add_action('plugins_loaded', 'scouting_oidc_init'); - -// Session session -add_action('init', [$scouting_oidc_session, 'scouting_oidc_session_start']); // Start session on init -add_action('wp_logout', [$scouting_oidc_session, 'scouting_oidc_session_end']); // End session on logout -add_action('wp_login', [$scouting_oidc_session, 'scouting_oidc_session_end']); // End session on login to reset - -// Add pages to the admin menu -add_action('admin_menu', [$scouting_oidc_menu, 'scouting_oidc_menu']); -add_action('admin_menu', [$scouting_oidc_settings, 'scouting_oidc_settings_submenu_page']); -add_action('admin_menu', [$scouting_oidc_shortcode, 'scouting_oidc_shortcode_submenu_page']); -add_action('admin_menu', [$scouting_oidc_support, 'scouting_oidc_support_submenu_page']); - -// Hook into admin_init to initialize settings -add_action('admin_init', [$scouting_oidc_settings, 'scouting_oidc_settings_page_init']); - -// Callback to render settings page content -add_action('template_redirect', [$scouting_oidc_auth, 'scouting_oidc_auth_callback']); - -// Add login error message -add_filter('login_message', [$scouting_oidc_auth, 'scouting_oidc_auth_login_failed']); - -// Modify plugin description -add_filter('all_plugins', [$scouting_oidc_description, 'scouting_oidc_description_modify_plugin']); - -// Add display to safe style css for user profile fields -add_filter('safe_style_css', function( $styles ) { - $styles[] = 'display'; - return $styles; -}); - -// add login redirect -add_action('wp_login', [$scouting_oidc_auth, 'scouting_oidc_auth_login_redirect']); - -// add logout redirect -add_action('wp_logout', [$scouting_oidc_auth, 'scouting_oidc_auth_logout_redirect']); - -// Setup defaults during installation -register_activation_hook(__FILE__, [$scouting_oidc_settings, 'scouting_oidc_settings_install']); + + * @copyright 2024 Scouting Nederland + * @license GPLv3 + * @version 0.0.1 + * @link https://github.com/Scouting-nl/scouting-openid-connect + * + * @wordpress-plugin + * Plugin Name: Scouting OpenID Connect + * Plugin URI: https://github.com/Scouting-nl/scouting-openid-connect + * Description: WordPress plugin for logging in with Scouting Nederland OpenID Connect Server. + * Version: 0.0.1 + * Requires at least: 6.4.3 + * Requires PHP: 8.2 + * Author: Job van Koeveringe + * Author URI: https://jobvankoeveringe.com?utm_source=wordpress&utm_medium=plugin&utm_campaign=scouting_oidc + * License: GPLv3 + * License URI: https://www.gnu.org/licenses/gpl-3.0.html + * Text Domain: scouting-openid-connect + * Domain Path: /languages + **/ + +require_once plugin_dir_path(__FILE__) . 'src/auth/auth.php'; +require_once plugin_dir_path(__FILE__) . 'src/auth/session.php'; +require_once plugin_dir_path(__FILE__) . 'src/menu/menu.php'; +require_once plugin_dir_path(__FILE__) . 'src/settings/page.php'; +require_once plugin_dir_path(__FILE__) . 'src/shortcode/page.php'; +require_once plugin_dir_path(__FILE__) . 'src/support/page.php'; +require_once plugin_dir_path(__FILE__) . 'src/plugin/actions.php'; +require_once plugin_dir_path(__FILE__) . 'src/plugin/description.php'; +require_once plugin_dir_path(__FILE__) . 'src/user/fields.php'; + +use ScoutingOIDC\Auth; +use ScoutingOIDC\Session; +use ScoutingOIDC\Menu; +use ScoutingOIDC\Actions; +use ScoutingOIDC\Description; +use ScoutingOIDC\Settings; +use ScoutingOIDC\Shortcode; +use ScoutingOIDC\Support; +use ScoutingOIDC\Fields; + +$scouting_oidc_auth = new Auth(); +$scouting_oidc_session = new Session(); +$scouting_oidc_menu = new Menu(); +$scouting_oidc_actions = new Actions(); +$scouting_oidc_description = new Description(); +$scouting_oidc_settings = new Settings(); +$scouting_oidc_shortcode = new Shortcode(); +$scouting_oidc_support = new Support(); +$scouting_oidc_fields = new Fields(); + +// Init plugin +function scouting_oidc_init() +{ + global $scouting_oidc_auth, $scouting_oidc_actions, $scouting_oidc_fields, $scouting_oidc_shortcode; // Declare global variable + + // Add translations to the plugin + load_plugin_textdomain('scouting-openid-connect', false, dirname(plugin_basename(__FILE__)) . '/languages'); + + // Add the OpenID Connect button to the login form + add_action('login_form', array($scouting_oidc_auth, 'scouting_oidc_auth_login_form')); + + // Create shortcodes for OpenID Connect button and link + add_shortcode('scouting_oidc_button', array($scouting_oidc_auth, 'scouting_oidc_auth_login_button_shortcode')); + add_shortcode('scouting_oidc_link', array($scouting_oidc_auth, 'scouting_oidc_auth_login_url_shortcode')); + + // Geef extra links in de plugin-overzichtspagina + add_filter('plugin_action_links_'.plugin_basename(__FILE__), [$scouting_oidc_actions, 'scouting_oidc_actions_plugin_links']); + + // Add scouting ID, birthday and gender to user profile + if (get_option('scouting_oidc_user_scouting_id') || get_option('scouting_oidc_user_birthday') || get_option('scouting_oidc_user_gender')) + { + add_action('show_user_profile', [$scouting_oidc_fields, 'scouting_oidc_fields_user_profile']); + add_action('edit_user_profile', [$scouting_oidc_fields, 'scouting_oidc_fields_user_profile']); + } + + // Add infix field to user profile + add_action('show_user_profile', [$scouting_oidc_fields, 'scouting_oidc_fields_show_infix_field']); + add_action('edit_user_profile', [$scouting_oidc_fields, 'scouting_oidc_fields_show_infix_field']); + add_action('admin_enqueue_scripts', [$scouting_oidc_fields, 'scouting_oidc_fields_enqueue_infix_field_script']); + add_action('admin_enqueue_scripts', [$scouting_oidc_shortcode, 'scouting_oidc_shortcode_enqueue_live_script']); +} +add_action('plugins_loaded', 'scouting_oidc_init'); + +// Session session +add_action('init', [$scouting_oidc_session, 'scouting_oidc_session_start']); // Start session on init +add_action('wp_logout', [$scouting_oidc_session, 'scouting_oidc_session_end']); // End session on logout +add_action('wp_login', [$scouting_oidc_session, 'scouting_oidc_session_end']); // End session on login to reset + +// Add pages to the admin menu +add_action('admin_menu', [$scouting_oidc_menu, 'scouting_oidc_menu']); +add_action('admin_menu', [$scouting_oidc_settings, 'scouting_oidc_settings_submenu_page']); +add_action('admin_menu', [$scouting_oidc_shortcode, 'scouting_oidc_shortcode_submenu_page']); +add_action('admin_menu', [$scouting_oidc_support, 'scouting_oidc_support_submenu_page']); + +// Hook into admin_init to initialize settings +add_action('admin_init', [$scouting_oidc_settings, 'scouting_oidc_settings_page_init']); + +// Callback to render settings page content +add_action('template_redirect', [$scouting_oidc_auth, 'scouting_oidc_auth_callback']); + +// Add login error message +add_filter('login_message', [$scouting_oidc_auth, 'scouting_oidc_auth_login_failed']); + +// Modify plugin description +add_filter('all_plugins', [$scouting_oidc_description, 'scouting_oidc_description_modify_plugin']); + +// Add display to safe style css for user profile fields +add_filter('safe_style_css', function( $styles ) { + $styles[] = 'display'; + return $styles; +}); + +// add login redirect +add_action('wp_login', [$scouting_oidc_auth, 'scouting_oidc_auth_login_redirect']); + +// add logout redirect +add_action('wp_logout', [$scouting_oidc_auth, 'scouting_oidc_auth_logout_redirect']); + +// Setup defaults during installation +register_activation_hook(__FILE__, [$scouting_oidc_settings, 'scouting_oidc_settings_install']); ?> \ No newline at end of file diff --git a/src/auth/OpenIDConnectClient.php b/src/auth/OpenIDConnectClient.php index ba967f1..9bb178f 100644 --- a/src/auth/OpenIDConnectClient.php +++ b/src/auth/OpenIDConnectClient.php @@ -122,7 +122,7 @@ public function getAuthenticationURL($response_type, $scopes_array) { return $this->wellKnownData->authorization_endpoint . '?' . http_build_query($auth_params, '', '&', PHP_QUERY_RFC1738); } - + /** * Retrieves the tokens from the token endpoint * @@ -321,7 +321,7 @@ private function getWellKnownData() { $this->wellKnownData = json_decode(wp_remote_retrieve_body($response)); } } - + /** * Sets the scopes * @@ -428,6 +428,7 @@ public function getNonce() { private function unsetNonce() { $this->session->scouting_oidc_session_delete('scouting_oidc_nonce'); } + /** * Adds a state to the stored array of states. * diff --git a/src/auth/auth.php b/src/auth/auth.php index d5f0b10..624e0db 100644 --- a/src/auth/auth.php +++ b/src/auth/auth.php @@ -3,8 +3,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly -require_once 'OpenIDConnectClient.php'; -require_once __DIR__.'/../../src/user/user.php'; +require_once plugin_dir_path(__FILE__) .'OpenIDConnectClient.php'; +require_once plugin_dir_path(__FILE__) . '../../src/user/user.php'; use ScoutingOIDC\User; diff --git a/src/settings/general.php b/src/settings/general.php index fdd6c84..9b4c07a 100644 --- a/src/settings/general.php +++ b/src/settings/general.php @@ -119,10 +119,10 @@ public function scouting_oidc_settings_general() { 'scouting_oidc_login_redirect' // Option name ); } - + // Callback to render section content public function scouting_oidc_settings_general_callback() {} - + // Callback to render text field public function scouting_oidc_settings_general_display_name_callback() { $possible_values = array( @@ -142,7 +142,7 @@ public function scouting_oidc_settings_general_display_name_callback() { } echo ''; } - + // Callback to render text field public function scouting_oidc_settings_general_birthdate_callback() { if (get_option('scouting_oidc_user_birthdate')) @@ -150,7 +150,7 @@ public function scouting_oidc_settings_general_birthdate_callback() { else echo ''; } - + // Callback to render text field public function scouting_oidc_settings_general_gender_callback() { if (get_option('scouting_oidc_user_gender')) @@ -158,7 +158,7 @@ public function scouting_oidc_settings_general_gender_callback() { else echo ''; } - + // Callback to render text field public function scouting_oidc_settings_general_scouting_id_callback() { if (get_option('scouting_oidc_user_scouting_id')) @@ -166,7 +166,7 @@ public function scouting_oidc_settings_general_scouting_id_callback() { else echo ''; } - + // Callback to render text field public function scouting_oidc_settings_general_user_auto_create_callback() { if (get_option('scouting_oidc_user_auto_create')) @@ -174,15 +174,14 @@ public function scouting_oidc_settings_general_user_auto_create_callback() { else echo ''; } - - + // Callback to render text field public function scouting_oidc_settings_general_user_name_prefix_callback() { $value = get_option('scouting_oidc_user_name_prefix'); echo ''; echo '

' . esc_html__("This prefix will be added to the username of all Scouting Nederland users", "scouting-openid-connect") . '

'; } - + // callback to render select field for login redirect public function scouting_oidc_settings_general_login_redirect_callback() { $possible_values = array( diff --git a/src/settings/oidc.php b/src/settings/oidc.php index b000b12..186473c 100644 --- a/src/settings/oidc.php +++ b/src/settings/oidc.php @@ -59,22 +59,22 @@ function scouting_oidc_settings_oidc() { 'scouting_oidc_scopes' // Option name ); } - + // Callback to render section content function scouting_oidc_settings_oidc_callback() {} - + // Callback to render text field function scouting_oidc_settings_oidc_client_id_callback() { $value = get_option('scouting_oidc_client_id'); echo ''; } - + // Callback to render text field function scouting_oidc_settings_oidc_client_secret_callback() { $value = get_option('scouting_oidc_client_secret'); echo ''; } - + // Callback to render text field function scouting_oidc_settings_oidc_scopes_callback() { $value = get_option('scouting_oidc_scopes'); diff --git a/src/settings/page.php b/src/settings/page.php index 32d9b57..da632da 100644 --- a/src/settings/page.php +++ b/src/settings/page.php @@ -3,8 +3,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly -include_once 'oidc.php'; -include_once 'general.php'; +require_once plugin_dir_path(__FILE__) . 'oidc.php'; +require_once plugin_dir_path(__FILE__) . 'general.php'; use ScoutingOIDC\Settings_Oidc; use ScoutingOIDC\Settings_General; diff --git a/src/shortcode/page.php b/src/shortcode/page.php index 69279e9..033a9e2 100644 --- a/src/shortcode/page.php +++ b/src/shortcode/page.php @@ -106,13 +106,13 @@ public function scouting_oidc_shortcode_page_callback() { public function scouting_oidc_shortcode_enqueue_live_script() { // Enqueue the external JavaScript file with the defer attribute wp_enqueue_script( - 'live-shortcode-script', // Handle name + 'live-shortcode-script', // Handle name plugins_url('live-shortcode.js', __FILE__), // Path to the file - array(), // No dependencies - "0.0.1", // Version number + array(), // No dependencies + "0.0.1", // Version number array( - 'strategy' => 'defer', // Add the defer attribute - 'in_footer' => true // Load the script in the footer + 'strategy' => 'defer', // Add the defer attribute + 'in_footer' => true // Load the script in the footer ) ); } diff --git a/src/support/page.php b/src/support/page.php index 742a07f..96ba29d 100644 --- a/src/support/page.php +++ b/src/support/page.php @@ -1,58 +1,58 @@ - -
-

-

- sol.scouting.nl. -

- -

-
    -
  1. https://login.scouting.nl,
  2. -
  3. -
  4. -
  5. -
  6. -
  7. -
  8. -
  9. -
  10. -
  11. - settings page. -
  12. -
  13. -
  14. -
  15. .
  16. -
  17. -
- -

-

- cms@support.scouting.nl & job.van.koeveringe@scouting.nl - . -

-
- +
+

+

+ sol.scouting.nl. +

+ +

+
    +
  1. login.scouting.nl,
  2. +
  3. +
  4. +
  5. +
  6. +
  7. +
  8. +
  9. +
  10. +
  11. + settings page. +
  12. +
  13. +
  14. +
  15. .
  16. +
  17. +
+ +

+

+ cms@support.scouting.nl & job.van.koeveringe@scouting.nl + . +

+
+ \ No newline at end of file diff --git a/src/user/fields.php b/src/user/fields.php index ac6e430..fb82a6a 100644 --- a/src/user/fields.php +++ b/src/user/fields.php @@ -1,121 +1,121 @@ - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- 'defer', // Add the defer attribute - 'in_footer' => true // Load the script in the footer - ) - ); - } -} + +

+ + + scouting_oidc_fields_scouting_id($user); + } + if (get_option('scouting_oidc_user_birthdate')) { + $this->scouting_oidc_fields_birthdate($user); + } + if (get_option('scouting_oidc_user_gender')) { + $this->scouting_oidc_fields_gender($user); + } + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ 'defer', // Add the defer attribute + 'in_footer' => true // Load the script in the footer + ) + ); + } +} ?> \ No newline at end of file diff --git a/src/user/user.php b/src/user/user.php index 4da1807..89d4510 100644 --- a/src/user/user.php +++ b/src/user/user.php @@ -1,214 +1,214 @@ -userName = get_option('scouting_oidc_user_name_prefix').$user_json_decoded['sub']; - $this->email = $user_json_decoded['email'] ?? null; - $this->emailVerified = $user_json_decoded['email_verified'] ?? false; - $this->sol_id = $user_json_decoded['member_id'] ?? ""; - $this->fullName = $user_json_decoded['name'] ?? ""; - $this->firstName = $user_json_decoded['given_name'] ?? ""; - $this->infix = $user_json_decoded['infix'] ?? ""; - $this->familyName = $user_json_decoded['family_name'] ?? ""; - $this->gender = $user_json_decoded['gender'] ?? "unknown"; - $this->birthdate = $user_json_decoded['birthdate'] ?? ""; - - if ($this->email == null) { - $hint = rawurlencode(__('Email scope is missing', 'scouting-openid-connect')); - $redirect_url = esc_url_raw(wp_login_url() . "?error_description=error&hint={$hint}&message=email_is_missing"); - wp_safe_redirect($redirect_url); - exit; - } - } - - /** - * Check if user already exists - * - * @return bool True if user exists, false otherwise - */ - public function scouting_oidc_user_check_if_exist() { - $user_id = username_exists($this->userName); - $email_id = email_exists($this->email); - - if (!$user_id && !$email_id) { - return false; - } - - return true; - } - - /** - * Create a new user - * - * @return int User ID - */ - public function scouting_oidc_user_create() { - $user_id = wp_create_user($this->userName, wp_generate_password(18, true, true), $this->email); - - if (is_wp_error($user_id)) { - return 0; - } - - $this-scouting_oidc_user_update_meta($user_id); - - return $user_id; - } - - /** - * Update user meta data - * - * @param int $user_id User ID - */ - public function scouting_oidc_user_update_meta(int $user_id) { - update_user_meta($user_id, 'first_name', $this->firstName); - update_user_meta($user_id, 'scouting_oidc_infix', $this->infix); - update_user_meta($user_id, 'last_name', $this->familyName); - update_user_meta($user_id, 'show_admin_bar_front', 'false'); - - if (get_option('scouting_oidc_user_display_name')) { - switch (get_option('scouting_oidc_user_display_name')) { - case 'firstname': - $display_name = $this->firstName; - break; - case 'lastname': - $display_name = $this->infix.$this->familyName; - break; - case 'username': - $display_name = $this->userName; - break; - case 'fullname': - default: - $display_name = $this->fullName; - break; - } - - update_user_meta($user_id, 'nickname', $display_name); - wp_update_user(array('ID' => $user_id, 'display_name' => $display_name)); - } - - if (get_option('scouting_oidc_user_scouting_id')) { - update_user_meta($user_id, 'scouting_oidc_id', $this->sol_id); - } - - if (get_option('scouting_oidc_user_gender')) { - update_user_meta($user_id, 'scouting_oidc_gender', $this->gender); - } - - if (get_option('scouting_oidc_user_birthdate')) { - update_user_meta($user_id, 'scouting_oidc_birthdate', $this->birthdate); - } - } - - /** - * Update user data if user already exists - */ - public function scouting_oidc_user_update() { - $user_name = username_exists($this->userName); - $email = email_exists($this->email); - - if ($user_name && $email) - { - $user_username = get_user_by('login', $this->userName); - $user_email = get_user_by('email', $this->email); - - if ($user_username->ID == $user_email->ID) { - $user = $user_username; - } - else { - $hint = rawurlencode(__('Username and Email have different user ID', 'scouting-openid-connect')); - $redirect_url = esc_url_raw(wp_login_url() . "?error_description=error&hint={$hint}&message=login_email_mismatch"); - wp_safe_redirect($redirect_url); - exit; - } - } - else if ($user_name) { - $user = get_user_by('login', $this->userName); - - //update email - wp_update_user(array('ID' => $user->ID, 'user_email' => $this->email)); - } - else if ($email) { - $user = get_user_by('email', $this->email); - } - - $this->scouting_oidc_user_update_meta($user->ID); - } - - /** - * Login user - * - * @return bool True if user is logged in, false otherwise - */ - public function scouting_oidc_user_login() { - $user = get_user_by('login', $this->userName); - - if (!$user) { - $hint = rawurlencode(__('Something went wrong while trying to log in', 'scouting-openid-connect')); - $redirect_url = esc_url_raw(wp_login_url() . "?error_description=error&hint={$hint}&message=login_email_mismatch"); - wp_safe_redirect($redirect_url); - exit; - } - - wp_set_current_user($user->ID, $user->user_login); - wp_set_auth_cookie($user->ID); - do_action('wp_login', $user->user_login); - } -} +userName = get_option('scouting_oidc_user_name_prefix').$user_json_decoded['sub']; + $this->email = $user_json_decoded['email'] ?? null; + $this->emailVerified = $user_json_decoded['email_verified'] ?? false; + $this->sol_id = $user_json_decoded['member_id'] ?? ""; + $this->fullName = $user_json_decoded['name'] ?? ""; + $this->firstName = $user_json_decoded['given_name'] ?? ""; + $this->infix = $user_json_decoded['infix'] ?? ""; + $this->familyName = $user_json_decoded['family_name'] ?? ""; + $this->gender = $user_json_decoded['gender'] ?? "unknown"; + $this->birthdate = $user_json_decoded['birthdate'] ?? ""; + + if ($this->email == null) { + $hint = rawurlencode(__('Email scope is missing', 'scouting-openid-connect')); + $redirect_url = esc_url_raw(wp_login_url() . "?error_description=error&hint={$hint}&message=email_is_missing"); + wp_safe_redirect($redirect_url); + exit; + } + } + + /** + * Check if user already exists + * + * @return bool True if user exists, false otherwise + */ + public function scouting_oidc_user_check_if_exist() { + $user_id = username_exists($this->userName); + $email_id = email_exists($this->email); + + if (!$user_id && !$email_id) { + return false; + } + + return true; + } + + /** + * Create a new user + * + * @return int User ID + */ + public function scouting_oidc_user_create() { + $user_id = wp_create_user($this->userName, wp_generate_password(18, true, true), $this->email); + + if (is_wp_error($user_id)) { + return 0; + } + + $this->scouting_oidc_user_update_meta($user_id); + + return $user_id; + } + + /** + * Update user meta data + * + * @param int $user_id User ID + */ + public function scouting_oidc_user_update_meta(int $user_id) { + update_user_meta($user_id, 'first_name', $this->firstName); + update_user_meta($user_id, 'scouting_oidc_infix', $this->infix); + update_user_meta($user_id, 'last_name', $this->familyName); + update_user_meta($user_id, 'show_admin_bar_front', 'false'); + + if (get_option('scouting_oidc_user_display_name')) { + switch (get_option('scouting_oidc_user_display_name')) { + case 'firstname': + $display_name = $this->firstName; + break; + case 'lastname': + $display_name = $this->infix.$this->familyName; + break; + case 'username': + $display_name = $this->userName; + break; + case 'fullname': + default: + $display_name = $this->fullName; + break; + } + + update_user_meta($user_id, 'nickname', $display_name); + wp_update_user(array('ID' => $user_id, 'display_name' => $display_name)); + } + + if (get_option('scouting_oidc_user_scouting_id')) { + update_user_meta($user_id, 'scouting_oidc_id', $this->sol_id); + } + + if (get_option('scouting_oidc_user_gender')) { + update_user_meta($user_id, 'scouting_oidc_gender', $this->gender); + } + + if (get_option('scouting_oidc_user_birthdate')) { + update_user_meta($user_id, 'scouting_oidc_birthdate', $this->birthdate); + } + } + + /** + * Update user data if user already exists + */ + public function scouting_oidc_user_update() { + $user_name = username_exists($this->userName); + $email = email_exists($this->email); + + if ($user_name && $email) + { + $user_username = get_user_by('login', $this->userName); + $user_email = get_user_by('email', $this->email); + + if ($user_username->ID == $user_email->ID) { + $user = $user_username; + } + else { + $hint = rawurlencode(__('Username and Email have different user ID', 'scouting-openid-connect')); + $redirect_url = esc_url_raw(wp_login_url() . "?error_description=error&hint={$hint}&message=login_email_mismatch"); + wp_safe_redirect($redirect_url); + exit; + } + } + else if ($user_name) { + $user = get_user_by('login', $this->userName); + + //update email + wp_update_user(array('ID' => $user->ID, 'user_email' => $this->email)); + } + else if ($email) { + $user = get_user_by('email', $this->email); + } + + $this->scouting_oidc_user_update_meta($user->ID); + } + + /** + * Login user + * + * @return bool True if user is logged in, false otherwise + */ + public function scouting_oidc_user_login() { + $user = get_user_by('login', $this->userName); + + if (!$user) { + $hint = rawurlencode(__('Something went wrong while trying to log in', 'scouting-openid-connect')); + $redirect_url = esc_url_raw(wp_login_url() . "?error_description=error&hint={$hint}&message=login_email_mismatch"); + wp_safe_redirect($redirect_url); + exit; + } + + wp_set_current_user($user->ID, $user->user_login); + wp_set_auth_cookie($user->ID); + do_action('wp_login', $user->user_login); + } +} ?> \ No newline at end of file