[server][auth] Auto create accounts from certain domains

This commit is contained in:
Abhishek Shroff
2025-06-26 11:48:00 +05:30
parent 38b39dbc03
commit fd42fbfbea
4 changed files with 36 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"embed"
"errors"
"fmt"
"os"
"path"
"strings"
@@ -150,6 +151,7 @@ func SetupCommand() {
fs.SetupCommand(),
user.SetupCommand(),
serve.SetupCommand(),
createLDAPTestCommand(),
)
cmd.AddGroup(&cobra.Group{ID: "misc", Title: "Misc"})
cmd.SetHelpCommandGroupID("misc")
@@ -157,6 +159,21 @@ func SetupCommand() {
cmd.Execute()
}
func createLDAPTestCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "ldap",
}
cmd.Run = func(c *cobra.Command, args []string) {
if u, err := auth.VerifyUserPassword(db.Get(context.Background()), "ldaptest@kudosoft.net", "asdfasdf"); err != nil {
fmt.Println(err.Error())
} else {
fmt.Printf("%+v\n", u)
}
}
return cmd
}
func isCmd(cmd *cobra.Command, s string) bool {
for c := cmd; c != nil; c = c.Parent() {
if cmd.Name() == s {

View File

@@ -17,8 +17,8 @@ core:
permission: 0x10 # Invite users
auth:
auto_create:
- "@example.com"
auto_create_domains:
- example.com
password:
backend: crypt
crypt: