Merge pull request #8 from benyanke/master

Added optional fields with sane defaults
This commit is contained in:
Ben Yanke
2018-04-18 20:13:01 -05:00
committed by GitHub
4 changed files with 82 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
# Ignore default config file for testing
glauth.cfg
# Ignore the built binary during testing
glauth
+37
View File
@@ -67,6 +67,43 @@ In order to use S3, you must set your AWS credentials. Either:
More configuration options are documented here: https://github.com/nmcclain/glauth/blob/master/sample-simple.cfg
### Required Fields
* Name
* The user's username
* ou
* ID of the user's primary group
* uidbumber
* The user's unix user id
* sshPublicKey
* Specify an array of public keys
### Optional Fields
* givenname
* First name
* Example: John
* default = blank
* sn
* Last name
* Example: Doe
* default = blank
* disabled
* Specify if account is active.
* Set to 'true' (without quotes) to make the LDAP entry add 'AccountStatus = inactive'
* default = false (active)
* mail
* Specify an email
* example: jdoe@example.com
* default = blank
* loginshell
* Specify a different login shell for the user
* Example: /bin/sh, or /sbin/nologin
* default = /bin/bash
* homedirectory
* Specify an overridden home directory for the user
* Example: /home/itadmin
* default = /home/[username]
### OpenSSH keys:
GLAuth can store a user's SSH authorized keys. Add one or more keys per user as shown above, then setup the goklp helper: https://github.com/appliedtrust/goklp
+34 -3
View File
@@ -132,12 +132,43 @@ func (h configHandler) Search(bindDN string, searchReq ldap.SearchRequest, conn
attrs := []*ldap.EntryAttribute{}
attrs = append(attrs, &ldap.EntryAttribute{"cn", []string{u.Name}})
attrs = append(attrs, &ldap.EntryAttribute{"uid", []string{u.Name}})
if len(u.GivenName) > 0 {
attrs = append(attrs, &ldap.EntryAttribute{"givenName", []string{u.GivenName}})
}
if len(u.SN) > 0 {
attrs = append(attrs, &ldap.EntryAttribute{"sn", []string{u.SN}})
}
attrs = append(attrs, &ldap.EntryAttribute{"ou", []string{h.getGroupName(u.PrimaryGroup)}})
attrs = append(attrs, &ldap.EntryAttribute{"uidNumber", []string{fmt.Sprintf("%d", u.UnixID)}})
attrs = append(attrs, &ldap.EntryAttribute{"accountStatus", []string{"active"}})
if (u.Disabled) {
attrs = append(attrs, &ldap.EntryAttribute{"accountStatus", []string{"inactive"}})
} else {
attrs = append(attrs, &ldap.EntryAttribute{"accountStatus", []string{"active"}})
}
if len(u.Mail) > 0 {
attrs = append(attrs, &ldap.EntryAttribute{"mail", []string{u.Mail}})
}
attrs = append(attrs, &ldap.EntryAttribute{"objectClass", []string{"posixAccount"}})
attrs = append(attrs, &ldap.EntryAttribute{"homeDirectory", []string{"/home/" + u.Name}})
attrs = append(attrs, &ldap.EntryAttribute{"loginShell", []string{"/bin/bash"}})
if len(u.LoginShell) > 0 {
attrs = append(attrs, &ldap.EntryAttribute{"loginShell", []string{u.LoginShell}})
} else {
attrs = append(attrs, &ldap.EntryAttribute{"loginShell", []string{"/bin/bash"}})
}
if len(u.Homedir) > 0 {
attrs = append(attrs, &ldap.EntryAttribute{"homeDirectory", []string{u.Homedir}})
} else {
attrs = append(attrs, &ldap.EntryAttribute{"homeDirectory", []string{"/home/" + u.Name}})
}
attrs = append(attrs, &ldap.EntryAttribute{"description", []string{fmt.Sprintf("%s via LDAP", u.Name)}})
attrs = append(attrs, &ldap.EntryAttribute{"gecos", []string{fmt.Sprintf("%s via LDAP", u.Name)}})
attrs = append(attrs, &ldap.EntryAttribute{"gidNumber", []string{fmt.Sprintf("%d", u.PrimaryGroup)}})
+6
View File
@@ -73,7 +73,13 @@ type configUser struct {
PassSHA256 string
PrimaryGroup int
SSHKeys []string
Disabled bool
UnixID int
Mail string
LoginShell string
GivenName string
SN string
Homedir string
}
type configGroup struct {
Name string