24 Commits
Author SHA1 Message Date
alu 1c11acface update default listen port to 80 2024-06-20 03:18:42 +00:00
alu 481922d384 add Makefile, move systemd service file to init folder 2024-06-20 03:03:11 +00:00
alu fb06f6b358 move config template to configs folder 2024-06-20 02:33:30 +00:00
alu b42ce808ab rewrite api in go/gin 2024-06-18 21:23:22 +00:00
Arthur Lu 067e327eb8 remove ldap setup scripts 2024-03-28 21:29:37 +00:00
Arthur Lu 04e8f0cac3 add starttls init script,
fix some bugs with init script
2024-01-26 03:31:00 +00:00
Arthur Lu 677f52b135 add password check to init.sh 2024-01-19 08:30:14 +00:00
Arthur Lu 981388784b update config.template.json,
update .gitignore,
fix required admin membership in openldap init,
add set cookie header to delete ticket endpoint
2024-01-19 08:02:10 +00:00
Arthur Lu 2b15c04be0 fix newline in paas.template.ldif 2024-01-18 04:53:26 +00:00
Arthur Lu bc0001dbb8 add admin email field 2024-01-18 04:50:09 +00:00
Arthur Lu d43520ba95 change paas to any admin user in init 2024-01-16 22:44:37 +00:00
Arthur Lu 34f9ff99ee fix linting 2024-01-12 01:48:34 +00:00
Arthur Lu c0fc119dc2 consolidate package and config import,
fix ldap auth template,
add start script and systemd service
2024-01-11 00:07:35 +00:00
Arthur Lu 8edfbe1ace add endpoints for session creation,
update package.json
2024-01-09 20:05:21 +00:00
Arthur Lu ec6eb5ec8b add get all user and get all groups endpoints 2023-12-22 04:20:31 +00:00
Arthur Lu 595d18b72f implement group member endpoints 2023-12-21 01:48:46 +00:00
Arthur Lu b63cce671c add group endpoints,
improve comments for other endpoints
2023-12-19 08:07:10 +00:00
Arthur Lu 77c556aa67 remove admin userPassword read permission,
implement user add mod get del endpoints
2023-12-15 23:20:43 +00:00
Arthur Lu ee666f6e08 add prototypes of api routes 2023-12-14 00:25:08 +00:00
Arthur Lu 87a42299e6 improve ldap wrapper return values 2023-12-01 23:06:15 +00:00
Arthur Lu 3ce798aced improve ldap return values,
fix addUserToGroup and delUser logic with user-group interaction
2023-11-30 04:28:49 +00:00
Arthur Lu b4ee79589b implement group methods,
implement modUser
2023-11-28 00:20:54 +00:00
Arthur Lu 9d6f62b4a3 fix openldap init script paas user token saving,
add config file with BASE_DN,
add async wrapper class for ldap client,
implement addUser getUser delUser,
add and implement addGroup delGroup methods
2023-11-17 19:49:11 +00:00
Arthur Lu d541062eda create openldap setup utilities,
prototype ldap api interface
2023-11-16 22:41:38 +00:00
5 changed files with 14 additions and 57 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
build: clean
CGO_ENABLED=0 go build -ldflags="-s -w" -o dist/ .
go build -ldflags="-s -w" -o dist/ .
test: clean
go run .
-36
View File
@@ -1,36 +0,0 @@
# ProxmoxAAS LDAP - Simple REST API for LDAP
ProxmoxAAS LDAP provides a simple API for managing users and groups in a simplified LDAP server. Expected LDAP configuration can be initialized using [open-ldap-setup](https://git.tronnet.net/tronnet/open-ldap-setup).
## Installation
### Prerequisites
- Initialized LDAP server with the following configuration
- Structure
- Users: ou=people,...
- objectType: inetOrgPerson
- At least 1 user which is a member of admin group
- Groups: ou=groups,...
- objectType: groupOfNames
- At least 1 admin group
- Permissions:
- Admin group should have write access
- Users should have write access to own attributes (cn, sn, userPassword)
- Enable anonymous binding
- Load MemberOf Policy:
- olcMemberOfDangling: ignore
- olcMemberOfRefInt: TRUE
- olcMemberOfGroupOC: groupOfNames
- olcMemberOfMemberAD: member
- olcMemberOfMemberOfAD: memberOf
- Password Policy and TLS are recommended but not required
### Installation
1. Download `proxmoxaas-ldap` binary and `template.config.json` file from [releases](releases)
2. Rename `template.config.json` to `config.json` and modify:
- ldapURL: url to the ldap server ie. `ldap://ldap.domain.net`
- baseDN: base DN ie. `dc=domain,dc=net`
- sessionSecretKey: random value used to randomize cookie values, replace with any sufficiently large random string
3. Run the binary
-5
View File
@@ -15,7 +15,6 @@ import (
)
var LDAPSessions map[string]*LDAPClient
var APIVersion = "1.0.1"
func Run() {
gob.Register(LDAPClient{})
@@ -39,10 +38,6 @@ func Run() {
LDAPSessions = make(map[string]*LDAPClient)
router.GET("/version", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"version": APIVersion})
})
router.POST("/ticket", func(c *gin.Context) {
var body Login
if err := c.ShouldBind(&body); err != nil { // bad request from binding
+12 -14
View File
@@ -34,8 +34,8 @@ func (l LDAPClient) GetAllUsers() (int, gin.H) {
searchRequest := ldap.NewSearchRequest(
l.peopledn, // The base dn to search
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
"(&(objectClass=inetOrgPerson))", // The filter to apply
[]string{"dn", "cn", "sn", "mail", "uid", "memberOf"}, // A list attributes to retrieve
"(&(objectClass=inetOrgPerson))", // The filter to apply
[]string{"dn", "cn", "sn", "mail", "uid"}, // A list attributes to retrieve
nil,
)
@@ -53,11 +53,10 @@ func (l LDAPClient) GetAllUsers() (int, gin.H) {
results = append(results, gin.H{
"dn": entry.DN,
"attributes": gin.H{
"cn": entry.GetAttributeValue("cn"),
"sn": entry.GetAttributeValue("sn"),
"mail": entry.GetAttributeValue("mail"),
"uid": entry.GetAttributeValue("uid"),
"memberOf": entry.GetAttributeValues("memberOf"),
"cn": entry.GetAttributeValue("cn"),
"sn": entry.GetAttributeValue("sn"),
"mail": entry.GetAttributeValue("mail"),
"uid": entry.GetAttributeValue("uid"),
},
})
}
@@ -104,8 +103,8 @@ func (l LDAPClient) GetUser(uid string) (int, gin.H) {
searchRequest := ldap.NewSearchRequest( // setup search for user by uid
fmt.Sprintf("uid=%s,%s", uid, l.peopledn), // The base dn to search
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
"(&(objectClass=inetOrgPerson))", // The filter to apply
[]string{"dn", "cn", "sn", "mail", "uid", "memberOf"}, // A list attributes to retrieve
"(&(objectClass=inetOrgPerson))", // The filter to apply
[]string{"dn", "cn", "sn", "mail", "uid"}, // A list attributes to retrieve
nil,
)
@@ -121,11 +120,10 @@ func (l LDAPClient) GetUser(uid string) (int, gin.H) {
result := gin.H{
"dn": entry.DN,
"attributes": gin.H{
"cn": entry.GetAttributeValue("cn"),
"sn": entry.GetAttributeValue("sn"),
"mail": entry.GetAttributeValue("mail"),
"uid": entry.GetAttributeValue("uid"),
"memberOf": entry.GetAttributeValues("memberOf"),
"cn": entry.GetAttributeValue("cn"),
"sn": entry.GetAttributeValue("sn"),
"mail": entry.GetAttributeValue("mail"),
"uid": entry.GetAttributeValue("uid"),
},
}
@@ -8,6 +8,6 @@
"path": "/",
"httpOnly": true,
"secure": false,
"maxAge": 7200
"maxAge": 7200000
}
}