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
5e5005cf
Commit
5e5005cf
authored
Feb 23, 2020
by
simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: ldap auth failed auth and added test scripts
parent
9fe25a8b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
8 deletions
+29
-8
package.json
package.json
+2
-1
src/auth/google-ldap.ts
src/auth/google-ldap.ts
+10
-7
tests/.gitignore
tests/.gitignore
+1
-0
tests/eapol_test
tests/eapol_test
+0
-0
tests/ttls-pap.conf
tests/ttls-pap.conf
+16
-0
No files found.
package.json
View file @
5e5005cf
...
@@ -7,7 +7,8 @@
...
@@ -7,7 +7,8 @@
"start"
:
"../node/node dist/app.js"
,
"start"
:
"../node/node dist/app.js"
,
"build"
:
"tsc"
,
"build"
:
"tsc"
,
"dev"
:
"ts-node src/app.ts"
,
"dev"
:
"ts-node src/app.ts"
,
"test-ttls-pap"
:
"eapol_test -c ./ttls-pap.conf -s testing123"
,
"test-ttls-pap"
:
"tests/eapol_test -c tests/ttls-pap.conf -s testing123"
,
"test-radtest"
:
"radtest -x user pwd localhost 1812 testing123"
,
"create-certificate"
:
"sh ./ssl/create.sh && sh ./ssl/sign.sh"
"create-certificate"
:
"sh ./ssl/create.sh && sh ./ssl/sign.sh"
},
},
"dependencies"
:
{
"dependencies"
:
{
...
...
src/auth/google-ldap.ts
View file @
5e5005cf
...
@@ -76,7 +76,7 @@ export class GoogleLDAPAuth implements IAuthentication {
...
@@ -76,7 +76,7 @@ export class GoogleLDAPAuth implements IAuthentication {
async authenticate(username: string, password: string, count = 0, forceFetching = false) {
async authenticate(username: string, password: string, count = 0, forceFetching = false) {
const cacheKey = `
usr
:
$
{
username
}
|pwd:
${
password
}
`
;
const cacheKey = `
usr
:
$
{
username
}
|pwd:
${
password
}
`
;
const
fromCache
=
this
.
cache
.
get
(
cacheKey
);
const
fromCache
=
this
.
cache
.
get
(
cacheKey
);
if
(
fromCache
)
{
if
(
fromCache
!==
undefined
)
{
return
fromCache
;
return
fromCache
;
}
}
...
@@ -100,10 +100,11 @@ export class GoogleLDAPAuth implements IAuthentication {
...
@@ -100,10 +100,11 @@ export class GoogleLDAPAuth implements IAuthentication {
if
(
!
dnsFetched
&&
!
forceFetching
)
{
if
(
!
dnsFetched
&&
!
forceFetching
)
{
return
this
.
authenticate
(
username
,
password
,
count
,
true
);
return
this
.
authenticate
(
username
,
password
,
count
,
true
);
}
}
throw
new
Error
(
`invalid username, not found in DN:
${
username
}
`
);
console
.
error
(
`invalid username, not found in DN:
${
username
}
`
);
return
false
;
}
}
await
new
Promise
((
resolve
,
reject
)
=>
{
const
authResult
:
boolean
=
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
ldap
.
bind
(
dn
,
password
,
(
err
,
res
)
=>
{
this
.
ldap
.
bind
(
dn
,
password
,
(
err
,
res
)
=>
{
if
(
err
)
{
if
(
err
)
{
if
(
err
&&
(
err
as
any
).
stack
&&
(
err
as
any
).
stack
.
includes
(
`
${
this
.
url
}
closed`
))
{
if
(
err
&&
(
err
as
any
).
stack
&&
(
err
as
any
).
stack
.
includes
(
`
${
this
.
url
}
closed`
))
{
...
@@ -112,16 +113,18 @@ export class GoogleLDAPAuth implements IAuthentication {
...
@@ -112,16 +113,18 @@ export class GoogleLDAPAuth implements IAuthentication {
setTimeout
(()
=>
resolve
(
this
.
authenticate
(
dn
,
password
)),
2000
);
setTimeout
(()
=>
resolve
(
this
.
authenticate
(
dn
,
password
)),
2000
);
return
;
return
;
}
}
console
.
error
(
'
ldap error
'
,
err
);
reject
(
err
);
resolve
(
false
);
// console.error('ldap error', err);
// reject(err);
}
}
if
(
res
)
resolve
(
res
);
if
(
res
)
resolve
(
res
);
else
reject
();
else
reject
();
});
});
});
});
this
.
cache
.
set
(
cacheKey
,
true
,
86400
);
this
.
cache
.
set
(
cacheKey
,
authResult
,
86400
);
return
username
;
return
authResult
;
}
}
}
}
tests/.gitignore
0 → 100644
View file @
5e5005cf
*hokify*
eapol_test
→
tests/
eapol_test
View file @
5e5005cf
File moved
tests/ttls-pap.conf
0 → 100644
View file @
5e5005cf
#
# eapol_test -c ttls-pap.conf -s testing123
#
network
={
ssid
=
"example"
key_mgmt
=
WPA
-
EAP
eap
=
TTLS
identity
=
"user"
anonymous_identity
=
"anonymous"
password
=
"pwd"
phase2
=
"auth=PAP"
#
# Uncomment the following to perform server certificate validation.
ca_cert
=
"./ssl/cert/ca.pem"
}
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