Skip to content

Commit e3ec646

Browse files
Approve lovable tool use
1 parent 4c470e6 commit e3ec646

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- Fix Auth security configuration issues
2+
3+
-- Set OTP expiry to recommended secure values (24 hours instead of default longer period)
4+
UPDATE auth.config
5+
SET
6+
otp_exp = 86400, -- 24 hours in seconds (recommended)
7+
password_min_length = 8, -- Minimum 8 characters
8+
enable_password_validation = true
9+
WHERE TRUE;
10+
11+
-- Enable leaked password protection
12+
UPDATE auth.config
13+
SET enable_password_validation = true
14+
WHERE TRUE;
15+
16+
-- Create function to enforce password security policies
17+
CREATE OR REPLACE FUNCTION public.validate_password_strength(password text)
18+
RETURNS boolean
19+
LANGUAGE plpgsql
20+
SECURITY DEFINER
21+
AS $$
22+
BEGIN
23+
-- Minimum 8 characters, at least one uppercase, one lowercase, one number
24+
RETURN length(password) >= 8
25+
AND password ~ '[A-Z]'
26+
AND password ~ '[a-z]'
27+
AND password ~ '[0-9]';
28+
END;
29+
$$;
30+
31+
-- Log security configuration changes
32+
SELECT public.log_security_event('auth_security_hardened', auth.uid(), '{"changes": ["otp_expiry_reduced", "password_validation_enabled"]}'::jsonb);

0 commit comments

Comments
 (0)