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
d9ff95bb
Commit
d9ff95bb
authored
Feb 28, 2020
by
simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(cli): allow setting config vars via cli
parent
e8b9462c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
21 deletions
+59
-21
config.js
config.js
+8
-6
src/app.ts
src/app.ts
+20
-3
src/auth/GoogleLDAPAuth.ts
src/auth/GoogleLDAPAuth.ts
+14
-5
src/auth/LDAPAuth.ts
src/auth/LDAPAuth.ts
+17
-7
No files found.
config.js
View file @
d9ff95bb
...
@@ -23,10 +23,10 @@ module.exports = {
...
@@ -23,10 +23,10 @@ module.exports = {
authentication
:
'
GoogleLDAPAuth
'
,
authentication
:
'
GoogleLDAPAuth
'
,
authenticationOptions
:
{
authenticationOptions
:
{
base
:
'
dc=hokify,dc=com
'
,
base
:
'
dc=hokify,dc=com
'
,
tlsOptions
:
{
// get your keys from http://admin.google.com/ -> Apps -> LDAP -> Client
// get your keys from http://admin.google.com/ -> Apps -> LDAP -> Client
tls
:
{
key
:
fs
.
readFileSync
(
'
ldap.gsuite.key
'
)
,
key
File
:
'
ldap.gsuite.key
'
,
cert
:
fs
.
readFileSync
(
'
ldap.gsuite.crt
'
)
cert
File
:
'
ldap.gsuite.crt
'
}
}
}
}
...
@@ -35,9 +35,11 @@ module.exports = {
...
@@ -35,9 +35,11 @@ module.exports = {
authenticationOptions: {
authenticationOptions: {
url: 'ldaps://ldap.google.com',
url: 'ldaps://ldap.google.com',
base: 'dc=hokify,dc=com',
base: 'dc=hokify,dc=com',
tls: {
keyFile: 'ldap.gsuite.key',
certFile: 'ldap.gsuite.crt'
},
tlsOptions: {
tlsOptions: {
key: fs.readFileSync('ldap.gsuite.key'),
cert: fs.readFileSync('ldap.gsuite.crt'),
servername: 'ldap.google.com'
servername: 'ldap.google.com'
}
}
}
}
...
...
src/app.ts
View file @
d9ff95bb
import
*
as
yargs
from
'
yargs
'
;
import
{
UDPServer
}
from
'
./server/UDPServer
'
;
import
{
UDPServer
}
from
'
./server/UDPServer
'
;
import
{
RadiusService
}
from
'
./radius/RadiusService
'
;
import
{
RadiusService
}
from
'
./radius/RadiusService
'
;
...
@@ -15,9 +16,25 @@ if (typeof (testSocket.tls as any).exportKeyingMaterial !== 'function') {
...
@@ -15,9 +16,25 @@ if (typeof (testSocket.tls as any).exportKeyingMaterial !== 'function') {
process
.
exit
(
-
1
);
process
.
exit
(
-
1
);
}
}
console
.
log
(
`Listener Port:
${
config
.
port
||
1812
}
`
);
const
{
argv
}
=
yargs
console
.
log
(
`RADIUS Secret:
${
config
.
secret
}
`
);
.
usage
(
'
NODE RADIUS Server
\n
Usage: radius-server
'
)
console
.
log
(
`Auth Mode:
${
config
.
authentication
}
`
);
.
example
(
'
radius-server --port 1812 -s radiussecret
'
)
.
default
({
port
:
config
.
port
||
1812
,
s
:
config
.
secret
||
'
testing123
'
,
authentication
:
config
.
authentication
,
authenticationOptions
:
config
.
authenticationOptions
})
.
describe
(
'
port
'
,
'
RADIUS server listener port
'
)
.
alias
(
'
s
'
,
'
secret
'
)
.
describe
(
'
secret
'
,
'
RADIUS secret
'
)
.
number
(
'
port
'
)
.
string
([
'
secret
'
,
'
authentication
'
]);
console
.
log
(
`Listener Port:
${
argv
.
port
||
1812
}
`
);
console
.
log
(
`RADIUS Secret:
${
argv
.
secret
}
`
);
console
.
log
(
`Auth
${
argv
.
authentication
}
`
);
console
.
log
(
`Auth Config:
${
JSON
.
stringify
(
argv
.
authenticationOptions
,
undefined
,
3
)}
`
);
(
async
()
=>
{
(
async
()
=>
{
/* configure auth mechansim */
/* configure auth mechansim */
...
...
src/auth/GoogleLDAPAuth.ts
View file @
d9ff95bb
import
{
ClientOptions
,
createClient
}
from
'
ldapjs
'
;
import
{
ClientOptions
,
createClient
}
from
'
ldapjs
'
;
import
debug
from
'
debug
'
;
import
debug
from
'
debug
'
;
import
*
as
tls
from
'
tls
'
;
import
*
as
tls
from
'
tls
'
;
import
*
as
fs
from
'
fs
'
;
import
{
IAuthentication
}
from
'
../types/Authentication
'
;
import
{
IAuthentication
}
from
'
../types/Authentication
'
;
const
usernameFields
=
[
'
posixUid
'
,
'
mail
'
];
const
usernameFields
=
[
'
posixUid
'
,
'
mail
'
];
...
@@ -13,12 +14,16 @@ interface IGoogleLDAPAuthOptions {
...
@@ -13,12 +14,16 @@ interface IGoogleLDAPAuthOptions {
/** base DN
/** base DN
* e.g. 'dc=hokify,dc=com', */
* e.g. 'dc=hokify,dc=com', */
base
:
string
;
base
:
string
;
tls
:
{
keyFile
:
string
;
certFile
:
string
;
};
/** tls options
/** tls options
* e.g. {
* e.g. {
key: fs.readFileSync('ldap.gsuite.key'),
key: fs.readFileSync('ldap.gsuite.key'),
cert: fs.readFileSync('ldap.gsuite.crt')
cert: fs.readFileSync('ldap.gsuite.crt')
} */
} */
tlsOptions
:
tls
.
TlsOptions
;
tlsOptions
?
:
tls
.
TlsOptions
;
}
}
export
class
GoogleLDAPAuth
implements
IAuthentication
{
export
class
GoogleLDAPAuth
implements
IAuthentication
{
...
@@ -33,12 +38,16 @@ export class GoogleLDAPAuth implements IAuthentication {
...
@@ -33,12 +38,16 @@ export class GoogleLDAPAuth implements IAuthentication {
constructor
(
config
:
IGoogleLDAPAuthOptions
)
{
constructor
(
config
:
IGoogleLDAPAuthOptions
)
{
this
.
base
=
config
.
base
;
this
.
base
=
config
.
base
;
const
tlsOptions
=
{
key
:
fs
.
readFileSync
(
config
.
tls
.
keyFile
),
cert
:
fs
.
readFileSync
(
config
.
tls
.
certFile
),
servername
:
'
ldap.google.com
'
,
...
config
.
tlsOptions
};
this
.
config
=
{
this
.
config
=
{
url
:
'
ldaps://ldap.google.com:636
'
,
url
:
'
ldaps://ldap.google.com:636
'
,
tlsOptions
:
{
tlsOptions
...
config
.
tlsOptions
,
servername
:
'
ldap.google.com
'
}
};
};
this
.
fetchDNs
();
this
.
fetchDNs
();
...
...
src/auth/LDAPAuth.ts
View file @
d9ff95bb
import
*
as
LdapAuth
from
'
ldapauth-fork
'
;
import
*
as
LdapAuth
from
'
ldapauth-fork
'
;
import
*
as
fs
from
'
fs
'
;
import
{
IAuthentication
}
from
'
../types/Authentication
'
;
import
{
IAuthentication
}
from
'
../types/Authentication
'
;
interface
ILDAPAuthOptions
{
interface
ILDAPAuthOptions
{
...
@@ -9,10 +10,13 @@ interface ILDAPAuthOptions {
...
@@ -9,10 +10,13 @@ interface ILDAPAuthOptions {
/** base DN
/** base DN
* e.g. 'dc=hokify,dc=com', */
* e.g. 'dc=hokify,dc=com', */
base
:
string
;
base
:
string
;
tls
:
{
keyFile
:
string
;
certFile
:
string
;
};
/** tls options
/** tls options
* e.g. {
* e.g. {
key: fs.readFileSync('ldap.gsuite.key'),
cert: fs.readFileSync('ldap.gsuite.crt'),
servername: 'ldap.google.com'
servername: 'ldap.google.com'
} */
} */
tlsOptions
?:
any
;
tlsOptions
?:
any
;
...
@@ -25,12 +29,18 @@ interface ILDAPAuthOptions {
...
@@ -25,12 +29,18 @@ interface ILDAPAuthOptions {
export
class
LDAPAuth
implements
IAuthentication
{
export
class
LDAPAuth
implements
IAuthentication
{
private
ldap
:
LdapAuth
;
private
ldap
:
LdapAuth
;
constructor
(
options
:
ILDAPAuthOptions
)
{
constructor
(
config
:
ILDAPAuthOptions
)
{
const
tlsOptions
=
{
key
:
fs
.
readFileSync
(
config
.
tls
.
keyFile
),
cert
:
fs
.
readFileSync
(
config
.
tls
.
certFile
),
...
config
.
tlsOptions
};
this
.
ldap
=
new
LdapAuth
({
this
.
ldap
=
new
LdapAuth
({
url
:
options
.
url
,
url
:
config
.
url
,
searchBase
:
options
.
base
,
searchBase
:
config
.
base
,
tlsOptions
:
options
.
tlsOptions
,
tlsOptions
,
searchFilter
:
options
.
searchFilter
||
'
(uid={{username}})
'
,
searchFilter
:
config
.
searchFilter
||
'
(uid={{username}})
'
,
reconnect
:
true
reconnect
:
true
});
});
this
.
ldap
.
on
(
'
error
'
,
function
(
err
)
{
this
.
ldap
.
on
(
'
error
'
,
function
(
err
)
{
...
...
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