| 42 | var EnableAuthentication = true |
| 43 | |
| 44 | func InitSuperuser(password string) { |
| 45 | auth.DropRole("doltgres") |
| 46 | auth.DropRole("postgres") |
| 47 | |
| 48 | var err error |
| 49 | postgres := auth.CreateDefaultRole("postgres") |
| 50 | postgres.CanLogin = true |
| 51 | postgres.Password, err = auth.NewScramSha256Password(password) |
| 52 | if err != nil { |
| 53 | panic(err) |
| 54 | } |
| 55 | auth.SetRole(postgres) |
| 56 | |
| 57 | // Postgres does not allow empty passwords, |
| 58 | // so we disable authentication if the superuser password is empty. |
| 59 | if password == "" { |
| 60 | EnableAuthentication = false |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // SASLBindingFlag are the flags for gs2-cbind-flag, used in SASL authentication. |
| 65 | type SASLBindingFlag string |