Home > Blockchain >  Postgres create user with expired password
Postgres create user with expired password

Time:10-28

How to create user if i want to force user to change password for the first time login to the database?

When i using code like

CREATE USER myUser WITH PASSWORD 'mypass' VALID UNTIL current_date
ERROR:  syntax error at or near "current_date"
LINE 1: ...REATE USER myUser WITH PASSWORD 'mypass' VALID UNTIL current_da...

CodePudding user response:

To do that, PostgreSQL would have to implement some restricted login capability which lets a person log in with an expired password, but then not let them do anything other than change the password. But it doesn't implement that. Once a password is expired, you need to get the superuser to reset it, or maybe login with some passwordless method (like locally from the database machine if configured with peer or trust) to reset it.

If you want advanced features like self-serve password resets, you should use a dedicated system like kerberos, Active Directory, etc. and hook PostgreSQL up to use them.

  • Related