apply ldap filtering rules to values being substituted into ldap filters
This commit is contained in:
parent
7bf37b35a5
commit
c738c86fd1
|
@ -4,6 +4,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tiagoapimenta/nginx-ldap-auth/ldap"
|
"github.com/tiagoapimenta/nginx-ldap-auth/ldap"
|
||||||
|
|
||||||
|
gldap "gopkg.in/ldap.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
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) {
|
func (p *Service) Find(id string) ([]string, error) {
|
||||||
|
id = gldap.EscapeFilter(id)
|
||||||
|
|
||||||
ok, _, groups, err := p.pool.Search(
|
ok, _, groups, err := p.pool.Search(
|
||||||
p.base,
|
p.base,
|
||||||
strings.Replace(p.filter, "{0}", id, -1),
|
strings.Replace(p.filter, "{0}", id, -1),
|
||||||
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tiagoapimenta/nginx-ldap-auth/ldap"
|
"github.com/tiagoapimenta/nginx-ldap-auth/ldap"
|
||||||
|
|
||||||
|
gldap "gopkg.in/ldap.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
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) {
|
func (p *Service) Find(username string) (bool, string, error) {
|
||||||
|
username = gldap.EscapeFilter(username)
|
||||||
|
|
||||||
ok, id, _, err := p.pool.Search(
|
ok, id, _, err := p.pool.Search(
|
||||||
p.base,
|
p.base,
|
||||||
strings.Replace(p.filter, "{0}", username, -1),
|
strings.Replace(p.filter, "{0}", username, -1),
|
||||||
|
|
Reference in a new issue