apply ldap filtering rules to values being substituted into ldap filters

This commit is contained in:
Gered 2019-06-28 11:40:10 -04:00
parent 7bf37b35a5
commit c738c86fd1
2 changed files with 8 additions and 0 deletions

View file

@ -4,6 +4,8 @@ import (
"strings"
"github.com/tiagoapimenta/nginx-ldap-auth/ldap"
gldap "gopkg.in/ldap.v2"
)
type Service struct {
@ -23,6 +25,8 @@ func NewService(pool *ldap.Pool, base, filter, attr string) *Service {
}
func (p *Service) Find(id string) ([]string, error) {
id = gldap.EscapeFilter(id)
ok, _, groups, err := p.pool.Search(
p.base,
strings.Replace(p.filter, "{0}", id, -1),

View file

@ -4,6 +4,8 @@ import (
"strings"
"github.com/tiagoapimenta/nginx-ldap-auth/ldap"
gldap "gopkg.in/ldap.v2"
)
type Service struct {
@ -21,6 +23,8 @@ func NewService(pool *ldap.Pool, base, filter string) *Service {
}
func (p *Service) Find(username string) (bool, string, error) {
username = gldap.EscapeFilter(username)
ok, id, _, err := p.pool.Search(
p.base,
strings.Replace(p.filter, "{0}", username, -1),