From b8f3f109b9a7d0fd2a4cd85bfac13354285859b2 Mon Sep 17 00:00:00 2001 From: Max Batischev Date: Fri, 28 Mar 2025 13:10:35 +0300 Subject: [PATCH] Add Support Postgres To JdbcUserCredentialRepository Closes gh-16832 Signed-off-by: Max Batischev --- .../aot/hint/UserCredentialRuntimeHints.java | 6 ++++-- .../user-credentials-schema-postgres.sql | 18 ++++++++++++++++++ .../hint/UserCredentialRuntimeHintsTests.java | 5 +++-- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 web/src/main/resources/org/springframework/security/user-credentials-schema-postgres.sql diff --git a/web/src/main/java/org/springframework/security/web/aot/hint/UserCredentialRuntimeHints.java b/web/src/main/java/org/springframework/security/web/aot/hint/UserCredentialRuntimeHints.java index c3b4c95a14..9670056872 100644 --- a/web/src/main/java/org/springframework/security/web/aot/hint/UserCredentialRuntimeHints.java +++ b/web/src/main/java/org/springframework/security/web/aot/hint/UserCredentialRuntimeHints.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,9 @@ class UserCredentialRuntimeHints implements RuntimeHintsRegistrar { @Override public void registerHints(RuntimeHints hints, ClassLoader classLoader) { - hints.resources().registerPattern("org/springframework/security/user-credentials-schema.sql"); + hints.resources() + .registerPattern("org/springframework/security/user-credentials-schema.sql") + .registerPattern("org/springframework/security/user-credentials-schema-postgres.sql"); } } diff --git a/web/src/main/resources/org/springframework/security/user-credentials-schema-postgres.sql b/web/src/main/resources/org/springframework/security/user-credentials-schema-postgres.sql new file mode 100644 index 0000000000..fb93b3869a --- /dev/null +++ b/web/src/main/resources/org/springframework/security/user-credentials-schema-postgres.sql @@ -0,0 +1,18 @@ +create table user_credentials +( + credential_id varchar(1000) not null, + user_entity_user_id varchar(1000) not null, + public_key bytea not null, + signature_count bigint, + uv_initialized boolean, + backup_eligible boolean not null, + authenticator_transports varchar(1000), + public_key_credential_type varchar(100), + backup_state boolean not null, + attestation_object bytea, + attestation_client_data_json bytea, + created timestamp, + last_used timestamp, + label varchar(1000) not null, + primary key (credential_id) +); diff --git a/web/src/test/java/org/springframework/security/web/aot/hint/UserCredentialRuntimeHintsTests.java b/web/src/test/java/org/springframework/security/web/aot/hint/UserCredentialRuntimeHintsTests.java index 33799cc6f9..ed44b4cb26 100644 --- a/web/src/test/java/org/springframework/security/web/aot/hint/UserCredentialRuntimeHintsTests.java +++ b/web/src/test/java/org/springframework/security/web/aot/hint/UserCredentialRuntimeHintsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,8 @@ void credentialRecordsSqlFilesHasHints(String schemaFile) { } private static Stream getClientRecordsSqlFiles() { - return Stream.of("org/springframework/security/user-credentials-schema.sql"); + return Stream.of("org/springframework/security/user-credentials-schema.sql", + "org/springframework/security/user-credentials-schema-postgres.sql"); } }