From f974bdb58340395955ca27bdd26d57062433ece9 Mon Sep 17 00:00:00 2001 From: Joel Lee Date: Sun, 18 Feb 2024 17:54:00 +0800 Subject: [PATCH] fix: populate password verification attempt hook (#1436) ## What kind of change does this PR introduce? We currently don't populate the hook name for the password verification hook. --------- Co-authored-by: joel --- internal/api/token_test.go | 8 ++++---- internal/conf/configuration.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/api/token_test.go b/internal/api/token_test.go index 6a8acf6d3b..0c8cc2377b 100644 --- a/internal/api/token_test.go +++ b/internal/api/token_test.go @@ -605,9 +605,9 @@ func (ts *TokenTestSuite) TestPasswordVerificationHook() { uri: "pg-functions://postgres/auth/password_verification_hook", hookFunctionSQL: ` create or replace function password_verification_hook(input jsonb) - returns json as $$ + returns jsonb as $$ begin - return json_build_object('decision', 'continue'); + return jsonb_build_object('decision', 'continue'); end; $$ language plpgsql;`, expectedCode: http.StatusOK, }, { @@ -615,9 +615,9 @@ func (ts *TokenTestSuite) TestPasswordVerificationHook() { uri: "pg-functions://postgres/auth/password_verification_hook_reject", hookFunctionSQL: ` create or replace function password_verification_hook_reject(input jsonb) - returns json as $$ + returns jsonb as $$ begin - return json_build_object('decision', 'reject'); + return jsonb_build_object('decision', 'reject', 'message', 'You shall not pass!'); end; $$ language plpgsql;`, expectedCode: http.StatusForbidden, }, diff --git a/internal/conf/configuration.go b/internal/conf/configuration.go index 3187b3abc8..c81bf4fa01 100644 --- a/internal/conf/configuration.go +++ b/internal/conf/configuration.go @@ -517,8 +517,8 @@ func LoadGlobal(filename string) (*GlobalConfiguration, error) { return nil, err } - if config.Hook.CustomAccessToken.Enabled { - if err := config.Hook.CustomAccessToken.PopulateExtensibilityPoint(); err != nil { + if config.Hook.PasswordVerificationAttempt.Enabled { + if err := config.Hook.PasswordVerificationAttempt.PopulateExtensibilityPoint(); err != nil { return nil, err } }