diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 1b4d1aa..48d0769 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -30,13 +30,13 @@ jobs: - name: Create artifact uses: montudor/action-zip@v0.1.0 with: - args: zip -X -r build/wp-openid.zip . -x *.git* node_modules/\* .* "*/\.*" CODE_OF_CONDUCT.md CONTRIBUTING.md ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md *.dist composer.* dev-helpers** build** + args: zip -X -r build/wp-openid-siu-upm.zip . -x *.git* node_modules/\* .* "*/\.*" CODE_OF_CONDUCT.md CONTRIBUTING.md ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md *.dist composer.* dev-helpers** build** - name: Upload artifact uses: actions/upload-artifact@v2 with: name: wp-openid - path: build/wp-openid.zip + path: build/wp-openid-siu-upm.zip - name: Update CHANGELOG id: changelog @@ -53,9 +53,9 @@ jobs: allowUpdates: true draft: false makeLatest: true - name: WP-OpenID - ${{ github.ref_name }} + name: WP-SIU-UPM - ${{ github.ref_name }} body: ${{ steps.changelog.outputs.changes }} - artifacts: build/wp-openid.zip + artifacts: build/wp-openid-siu-upm.zip replacesArtifacts: true - name: Commit CHANGELOG.md @@ -63,7 +63,7 @@ jobs: with: branch: main commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]' - commit_user_name: nicko170 [bot] - commit_user_email: 172472+nicko170[bot]@users.noreply.github.com + commit_user_name: Jenkins DAT-ETSIT + commit_user_email: jenkins-dat-etsit-upm@users.noreply.github.com file_pattern: CHANGELOG.md token: ${{ steps.generate_token.outputs.token }} diff --git a/OpenID.php b/OpenID.php index ee15993..76f2bb3 100644 --- a/OpenID.php +++ b/OpenID.php @@ -3,6 +3,7 @@ class OpenID { private ?string $metadata_url; + private ?string $redirect_uri; private ?string $client_id; private ?string $client_secret; private ?string $default_role; @@ -33,6 +34,7 @@ public function __construct() // General Options $this->is_network = is_plugin_active_for_network('wp-openid'); $this->metadata_url = defined('WP_OPENID_METADATA_URL') ? WP_OPENID_METADATA_URL : ($this->is_network ? get_site_option('openid_metadata_url') : get_option('openid_metadata_url')); + $this->redirect_uri = defined('WP_OPENID_REDIRECT_URI') ? WP_OPENID_REDIRECT_URI : ($this->is_network ? get_site_option('openid_redirect_uri') : get_option('openid_redirect_uri')); $this->client_id = defined('WP_OPENID_CLIENT_ID') ? WP_OPENID_CLIENT_ID : ($this->is_network ? get_site_option('openid_client_id') : get_option('openid_client_id')); $this->client_secret = defined('WP_OPENID_CLIENT_SECRET') ? WP_OPENID_CLIENT_SECRET : ($this->is_network ? get_site_option('openid_client_secret') : get_option('openid_client_secret')); $this->default_role = defined('WP_OPENID_DEFAULT_ROLE') ? WP_OPENID_DEFAULT_ROLE : ($this->is_network ? get_site_option('openid_default_role') : get_option('openid_default_role')); @@ -200,7 +202,7 @@ public function login_redirect(): bool 'response_type' => 'code', 'client_id' => $this->client_id, 'state' => $state['state'], - 'redirect_uri' => esc_url(add_query_arg('openid', 'callback', site_url('/wp-login.php'))), + 'redirect_uri' => esc_url(add_query_arg('openid', 'callback', $this->redirect_uri)), 'code_challenge' => $code_challenge, 'code_challenge_method' => 'S256', 'scope' => 'openid profile email', @@ -290,7 +292,7 @@ private function _get_token(string $code): array 'body' => [ 'grant_type' => 'authorization_code', 'code' => $code, - 'redirect_uri' => esc_url(add_query_arg('openid', 'callback', site_url('/wp-login.php'))), + 'redirect_uri' => esc_url(add_query_arg('openid', 'callback', $this->redirect_uri)), 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'code_verifier' => $state['verifier'], @@ -416,6 +418,7 @@ public function admin_init(): void { // General options register_setting('openid', 'openid_metadata_url'); + register_setting('openid', 'openid_redirect_uri'); register_setting('openid', 'openid_client_id'); register_setting('openid', 'openid_client_secret'); register_setting('openid', 'openid_default_role'); @@ -624,15 +627,19 @@ public function settings_page(): void

- If your OpenID provider supports provider initiated login, you can use the following settings: + Enter where you want to be redirected after login. By default, it should be

- + Redirect URI - +
@@ -847,6 +854,7 @@ public function save_settings(): void // Validate and save the settings update_site_option('openid_metadata_url', esc_url_raw(filter_var($_POST['openid_metadata_url'], FILTER_VALIDATE_URL) ?? '', ['https'])); + update_site_option('openid_redirect_uri', esc_url_raw(filter_var($_POST['openid_redirect_uri'], FILTER_VALIDATE_URL) ?? '', ['https'])); update_site_option('openid_client_id', sanitize_text_field($_POST['openid_client_id'] ?? '')); update_site_option('openid_client_secret', sanitize_text_field($_POST['openid_client_secret'] ?? '')); update_site_option('openid_default_role', sanitize_text_field($_POST['openid_default_role'] ?? '')); @@ -860,12 +868,14 @@ public function deactivate(): void { if ($this->is_network) { delete_site_option('openid_metadata_url'); + delete_site_option('openid_redirect_uri'); delete_site_option('openid_client_id'); delete_site_option('openid_client_secret'); delete_site_option('default_role'); delete_site_option('user_mapping'); } else { delete_option('openid_metadata_url'); + delete_option('openid_redirect_uri'); delete_option('openid_client_id'); delete_option('openid_client_secret'); delete_option('openid_default_role'); diff --git a/wp-openid.php b/wp-openid.php index 20d9977..57eb535 100644 --- a/wp-openid.php +++ b/wp-openid.php @@ -1,15 +1,15 @@ repository('nicko170/wp-openid') + ->repository('DAT-ETSIT/wp-siu-upm') ->asset_name('wp-openid.zip') - ->readme_url('https://raw.githubusercontent.com/nicko170/wp-openid/main/README.md') + ->readme_url('https://raw.githubusercontent.com/DAT-ETSIT/wp-siu-upm/main/README.md') ->boot(__FILE__); });