Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Node Radius Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Node Radius Server
Commits
0baf8155
Commit
0baf8155
authored
Feb 25, 2020
by
simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(auth): improve google auth
always instanciate a new client for bind request
parent
82f9a2e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
src/auth/GoogleLDAPAuth.ts
src/auth/GoogleLDAPAuth.ts
+15
-6
No files found.
src/auth/GoogleLDAPAuth.ts
View file @
0baf8155
import
{
Client
,
createClient
}
from
'
ldapjs
'
;
import
{
Client
,
ClientOptions
,
createClient
}
from
'
ldapjs
'
;
import
debug
from
'
debug
'
;
import
*
as
tls
from
'
tls
'
;
import
{
IAuthentication
}
from
'
../types/Authentication
'
;
...
...
@@ -22,7 +22,7 @@ interface IGoogleLDAPAuthOptions {
}
export
class
GoogleLDAPAuth
implements
IAuthentication
{
private
ldap
:
Client
;
private
ldap
DNClient
:
Client
;
private
lastDNsFetch
:
Date
;
...
...
@@ -30,16 +30,20 @@ export class GoogleLDAPAuth implements IAuthentication {
private
base
:
string
;
private
config
:
ClientOptions
;
constructor
(
config
:
IGoogleLDAPAuthOptions
)
{
this
.
base
=
config
.
base
;
this
.
ldap
=
createClient
(
{
this
.
config
=
{
url
:
'
ldaps://ldap.google.com:636
'
,
tlsOptions
:
{
...
config
.
tlsOptions
,
servername
:
'
ldap.google.com
'
}
}).
on
(
'
error
'
,
error
=>
{
};
this
.
ldapDNClient
=
createClient
(
this
.
config
).
on
(
'
error
'
,
error
=>
{
console
.
error
(
'
Error in ldap
'
,
error
);
});
...
...
@@ -50,7 +54,7 @@ export class GoogleLDAPAuth implements IAuthentication {
const
dns
:
{
[
key
:
string
]:
string
}
=
{};
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
ldap
.
search
(
this
.
ldap
DNClient
.
search
(
this
.
base
,
{
scope
:
'
sub
'
...
...
@@ -118,7 +122,10 @@ export class GoogleLDAPAuth implements IAuthentication {
}
const
authResult
:
boolean
=
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
ldap
.
bind
(
dn
,
password
,
(
err
,
res
)
=>
{
// we never unbding a client, therefore create a new client every time
const
authClient
=
createClient
(
this
.
config
);
authClient
.
bind
(
dn
,
password
,
(
err
,
res
)
=>
{
if
(
err
)
{
if
(
err
&&
(
err
as
any
).
stack
&&
(
err
as
any
).
stack
.
includes
(
`ldap.google.com closed`
))
{
count
++
;
...
...
@@ -133,6 +140,8 @@ export class GoogleLDAPAuth implements IAuthentication {
}
if
(
res
)
resolve
(
res
);
else
reject
();
authClient
.
unbind
();
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment