This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-19 22:30:27 +00:00
|
|
|
package ldap
|
|
|
|
|
|
|
|
import (
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"goauthentik.io/outpost/pkg/ak"
|
|
|
|
|
|
|
|
"github.com/nmcclain/ldap"
|
|
|
|
)
|
|
|
|
|
|
|
|
const GroupObjectClass = "group"
|
|
|
|
const UserObjectClass = "user"
|
|
|
|
|
2021-04-26 09:53:06 +00:00
|
|
|
type ProviderInstance struct {
|
2021-04-19 22:30:27 +00:00
|
|
|
BaseDN string
|
|
|
|
|
2021-04-26 09:53:06 +00:00
|
|
|
UserDN string
|
|
|
|
GroupDN string
|
|
|
|
|
|
|
|
appSlug string
|
|
|
|
flowSlug string
|
|
|
|
s *LDAPServer
|
|
|
|
log *log.Entry
|
|
|
|
}
|
2021-04-19 22:30:27 +00:00
|
|
|
|
2021-04-26 09:53:06 +00:00
|
|
|
type LDAPServer struct {
|
2021-04-19 22:30:27 +00:00
|
|
|
s *ldap.Server
|
|
|
|
log *log.Entry
|
|
|
|
ac *ak.APIController
|
2021-04-25 20:07:12 +00:00
|
|
|
|
2021-04-26 09:53:06 +00:00
|
|
|
providers []*ProviderInstance
|
2021-04-19 22:30:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewServer(ac *ak.APIController) *LDAPServer {
|
|
|
|
s := ldap.NewServer()
|
|
|
|
s.EnforceLDAP = true
|
|
|
|
ls := &LDAPServer{
|
2021-04-26 09:53:06 +00:00
|
|
|
s: s,
|
|
|
|
log: log.WithField("logger", "ldap-server"),
|
|
|
|
ac: ac,
|
|
|
|
providers: []*ProviderInstance{},
|
2021-04-19 22:30:27 +00:00
|
|
|
}
|
|
|
|
s.BindFunc("", ls)
|
|
|
|
s.SearchFunc("", ls)
|
|
|
|
return ls
|
|
|
|
}
|