Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
Expand Down Expand Up @@ -72,6 +72,7 @@ public UserDetailsService userDetailsService() {

@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
// Supports both encoded passwords (e.g. {bcrypt}) and explicit dev-only {noop} seeds.
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}
}
42 changes: 42 additions & 0 deletions src/main/resources/data-local.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,45 @@ VALUES (
NOW()
)
ON CONFLICT (email) DO NOTHING;

-- Local development only: seed patient accounts with visible (unhashed) passwords.
-- Credentials:
-- - john.doe@traumateam.com / patient123
-- - jane.smith@traumateam.com / patient123
-- - anders.andersson@traumateam.com / patient123
-- Note: "{noop}" means "do not hash" in Spring Security.
INSERT INTO user_account (id, email, password_hash, role, provider, enabled, created_at)
VALUES (
'550e8400-e29b-41d4-a716-446655440000',
'john.doe@traumateam.com',
'{noop}patient123',
'PATIENT',
'LOCAL',
true,
NOW()
)
ON CONFLICT (email) DO NOTHING;

INSERT INTO user_account (id, email, password_hash, role, provider, enabled, created_at)
VALUES (
'550e8400-e29b-41d4-a716-446655440001',
'jane.smith@traumateam.com',
'{noop}patient123',
'PATIENT',
'LOCAL',
true,
NOW()
)
ON CONFLICT (email) DO NOTHING;

INSERT INTO user_account (id, email, password_hash, role, provider, enabled, created_at)
VALUES (
'550e8400-e29b-41d4-a716-446655440002',
'anders.andersson@traumateam.com',
'{noop}patient123',
'PATIENT',
'LOCAL',
true,
NOW()
)
ON CONFLICT (email) DO NOTHING;
16 changes: 16 additions & 0 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ INSERT INTO user_account (id, email, password_hash, role, provider, provider_use
VALUES ('120e8400-e29b-41d4-a716-446655440002', 'patient.seed@traumateam.local', NULL, 'PATIENT', 'GITHUB', 'seed-patient-001', true, CURRENT_TIMESTAMP - INTERVAL '40 days')
ON CONFLICT (email) DO NOTHING;

INSERT INTO user_account (id, email, password_hash, role, provider, provider_user_id, enabled, created_at)
VALUES ('228023f0-e676-356e-ba78-097cc894cc5a', NULL, NULL, 'MANAGER', 'GITHUB', 'linuswestling', true, CURRENT_TIMESTAMP - INTERVAL '2 days')
ON CONFLICT (id) DO NOTHING;

INSERT INTO user_account (id, email, password_hash, role, provider, provider_user_id, enabled, created_at)
VALUES ('876a23e4-2207-3e12-b36c-c44e4a50f772', NULL, NULL, 'MANAGER', 'GITHUB', 'mattknatt', true, CURRENT_TIMESTAMP - INTERVAL '2 days')
ON CONFLICT (id) DO NOTHING;

-- ------------------------------------------------------------
-- Patients
-- ------------------------------------------------------------
Expand Down Expand Up @@ -65,6 +73,14 @@ INSERT INTO employees (id, display_name, github_username, role, created_at)
VALUES ('770e8400-e29b-41d4-a716-446655440004', 'Nurse Emma Karlsson', 'emma-karlsson-rn', 'NURSE', CURRENT_TIMESTAMP - INTERVAL '33 days')
ON CONFLICT (id) DO NOTHING;

INSERT INTO employees (id, display_name, github_username, role, created_at)
VALUES ('228023f0-e676-356e-ba78-097cc894cc5a', 'Linus Westling', 'linuswestling', 'MANAGER', CURRENT_TIMESTAMP - INTERVAL '2 days')
ON CONFLICT (id) DO NOTHING;

INSERT INTO employees (id, display_name, github_username, role, created_at)
VALUES ('876a23e4-2207-3e12-b36c-c44e4a50f772', 'Matt Knatt', 'mattknatt', 'MANAGER', CURRENT_TIMESTAMP - INTERVAL '2 days')
ON CONFLICT (id) DO NOTHING;

-- ------------------------------------------------------------
-- Cases
-- ------------------------------------------------------------
Expand Down