From baf742483d36f88113e6a863b7071fe0750cb4dc Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Mon, 23 Mar 2026 23:48:34 +0100 Subject: [PATCH] feat: OAuth Note repairs --- hosts/vm/mediakiwi/WSONoteKfetAuth/README | 2 +- hosts/vm/mediakiwi/WSONoteKfetAuth/extension.json | 2 +- .../vm/mediakiwi/WSONoteKfetAuth/src/NoteKfetAuth.php | 8 ++++---- hosts/vm/mediakiwi/mediawiki.nix | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hosts/vm/mediakiwi/WSONoteKfetAuth/README b/hosts/vm/mediakiwi/WSONoteKfetAuth/README index 0d3eae9..b13c920 100644 --- a/hosts/vm/mediakiwi/WSONoteKfetAuth/README +++ b/hosts/vm/mediakiwi/WSONoteKfetAuth/README @@ -9,6 +9,6 @@ Il faut enregistrer l'extension comme provider ``` $wgOAuthCustomAuthProviders = [ - 'note' => WSOAuthNoteKfetAuth\NoteKfetAuth::class + 'note' => WSOAuth\AuthenticationProvider\NoteKfetAuth::class ]; ``` diff --git a/hosts/vm/mediakiwi/WSONoteKfetAuth/extension.json b/hosts/vm/mediakiwi/WSONoteKfetAuth/extension.json index efbb583..b4d160f 100644 --- a/hosts/vm/mediakiwi/WSONoteKfetAuth/extension.json +++ b/hosts/vm/mediakiwi/WSONoteKfetAuth/extension.json @@ -13,7 +13,7 @@ } }, "AutoloadNamespaces": { - "WSONoteKfetAuth\\": "src/" + "WSOAuth\\AuthenticationProvider\\": "src/" }, "config": { "NoteKfetUrl": { diff --git a/hosts/vm/mediakiwi/WSONoteKfetAuth/src/NoteKfetAuth.php b/hosts/vm/mediakiwi/WSONoteKfetAuth/src/NoteKfetAuth.php index 464213c..73b5305 100644 --- a/hosts/vm/mediakiwi/WSONoteKfetAuth/src/NoteKfetAuth.php +++ b/hosts/vm/mediakiwi/WSONoteKfetAuth/src/NoteKfetAuth.php @@ -52,12 +52,12 @@ class NoteKfetAuth extends AuthProvider { $state = random_int(PHP_INT_MIN, PHP_INT_MAX); $secret = "$state"; - $authUrl = $GLOBALS['wgNoteKfetUrl'] . "o/authorize/?" . http_build_query( + $authUrl = $GLOBALS['wgNoteKfetUrl'] . "o/authorize/?" . http_build_query([ 'client_id' => $this->clientId, 'response_type' => 'code', 'scope' => '1_1', 'state' => $secret, - ); + ]); return true; } @@ -85,7 +85,7 @@ class NoteKfetAuth extends AuthProvider { $userInfos = $this->getUserInfos( $token ); return [ - 'name' => $userInfos->normalized_name, + 'name' => "note_$userInfos->normalized_name", 'realname' => $userInfos->username, 'email' => $userInfos->email, ]; @@ -111,7 +111,7 @@ class NoteKfetAuth extends AuthProvider { ]; $context = stream_context_create($options); - $response = file_get_contents($GLOBALS['wgNoteKfetUrl'] . 'o/oauth/token/', false, $context); + $response = file_get_contents($GLOBALS['wgNoteKfetUrl'] . 'o/token/', false, $context); $tokens = json_decode($response); return $tokens->access_token; } diff --git a/hosts/vm/mediakiwi/mediawiki.nix b/hosts/vm/mediakiwi/mediawiki.nix index 15cd91b..f3c2ec7 100644 --- a/hosts/vm/mediakiwi/mediawiki.nix +++ b/hosts/vm/mediakiwi/mediawiki.nix @@ -16,8 +16,8 @@ in owner = "mediawiki"; }; - age.secrets.mediawiki-openid = { - file = ../../../secrets/mediakiwi/mediawiki-openid.age; + age.secrets.mediawiki-oauth = { + file = ../../../secrets/mediakiwi/mediawiki-oauth.age; owner = "mediawiki"; }; @@ -107,7 +107,7 @@ in $LDAPAuthentication2AllowLocalLogin = true; $LDAPProviderDomainConfigs = "${config.age.secrets.mediawiki-ldap.path}"; $wgOAuthCustomAuthProviders = [ - 'note' => WSOAuthNoteKfetAuth\NoteKfetAuth::class + 'note' => WSOAuth\AuthenticationProvider\NoteKfetAuth::class ]; $wgPluggableAuth_Config = [ "Compte Crans" => [ @@ -267,9 +267,9 @@ in rev = "REL" + major + "_" + minor; # Le SHA doit être changé à chaque nouveau commit de traduction. # Pas de meilleure solution à ma connaissance pour suivre les releases. - sha256 = "sha256-1jv4nmkxky1dx7833sacsbqww54yb9glrnl1360b13h2z5fhwdxp"; + sha256 = "sha256-G2C/KuSgfWWftpHHhOABwFcOEb1zB8qmHi9KgrC6Jrc="; }; - WSONoteKfetAuth = ./WSONoteKfetAuth; + WSONoteKfetAuth = "${./WSONoteKfetAuth}"; }; }; }