mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-05 19:21:23 -06:00
[server][auth] Auto create accounts from certain domains
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -17,8 +17,8 @@ core:
|
||||
permission: 0x10 # Invite users
|
||||
|
||||
auth:
|
||||
auto_create:
|
||||
- "@example.com"
|
||||
auto_create_domains:
|
||||
- example.com
|
||||
password:
|
||||
backend: crypt
|
||||
crypt:
|
||||
|
||||
Reference in New Issue
Block a user