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
c31a1a91
Commit
c31a1a91
authored
Sep 25, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ci
parent
6dcc1b7c
Pipeline
#5830
passed with stages
in 2 minutes and 5 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
35 deletions
+115
-35
.dockerignore
.dockerignore
+15
-0
.gitlab-ci.yml
.gitlab-ci.yml
+43
-0
Dockerfile
Dockerfile
+11
-0
config.js
config.js
+7
-5
src/app.ts
src/app.ts
+17
-13
src/auth/HTTPAuth.ts
src/auth/HTTPAuth.ts
+22
-17
No files found.
.dockerignore
0 → 100644
View file @
c31a1a91
node_modules/*
.DS_Store
# build files
dist
# ts
tsconfig.tsbuildinfo
# custom certificates
/ssl-*/
.git*
Dockerfile
.dockerignore
.gitlab-ci.yml
0 → 100644
View file @
c31a1a91
stages
:
-
build
-
deploy
variables
:
GIT_DEPTH
:
"
1"
CONTAINER_TEST_IMAGE
:
$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_TEST_ARM_IMAGE
:
$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-arm
CONTAINER_TEST_X86_IMAGE
:
$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-x86
CONTAINER_RELEASE_IMAGE
:
$CI_REGISTRY_IMAGE:latest
before_script
:
-
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build-x86
:
stage
:
build
tags
:
-
docker
script
:
-
TARGET_IMAGE=$CONTAINER_TEST_IMAGE
-
docker build --pull -t $TARGET_IMAGE .
-
docker push $TARGET_IMAGE
deploy_latest
:
stage
:
deploy
tags
:
-
docker
script
:
-
TARGET_IMAGE=$CONTAINER_RELEASE_IMAGE
-
SOURCE_IMAGE=$CONTAINER_TEST_IMAGE
-
docker pull $SOURCE_IMAGE
-
docker tag $SOURCE_IMAGE $TARGET_IMAGE
-
docker push $TARGET_IMAGE
only
:
-
master
deploy_tag
:
stage
:
deploy
tags
:
-
docker
script
:
-
TARGET_IMAGE=$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
-
SOURCE_IMAGE=$CONTAINER_TEST_IMAGE
-
docker pull $SOURCE_IMAGE
-
docker tag $SOURCE_IMAGE $TARGET_IMAGE
-
docker push $TARGET_IMAGE
only
:
-
tags
Dockerfile
0 → 100644
View file @
c31a1a91
FROM
node:bullseye-slim
LABEL
Author="Nanahira <nanahira@momobako.com>"
RUN
apt update
&&
apt
-y
install
python3 build-essential
&&
rm
-rf
/var/lib/apt/lists/
*
/tmp/
*
/var/tmp/
*
WORKDIR
/usr/src/app
COPY
./package*.json ./
RUN
npm ci
COPY
. ./
RUN
npm run build
CMD
["npm", "run", "start"]
config.js
View file @
c31a1a91
...
...
@@ -5,10 +5,11 @@ const path = require('path');
const
SSL_CERT_DIRECTORY
=
path
.
join
(
__dirname
,
'
./ssl/cert
'
);
module
.
exports
=
{
port
:
1812
,
port
:
process
.
env
.
PORT
||
1812
,
// radius secret
secret
:
'
testing123
'
,
secret
:
process
.
env
.
SECRET
||
'
testing123
'
,
/*
certificate: {
cert: fs.readFileSync(path.join(SSL_CERT_DIRECTORY, '/server.crt')),
key: [
...
...
@@ -21,7 +22,9 @@ module.exports = {
// sesionIdContext: 'meiasdfkljasdft!',
// ticketKeys: Buffer.from('123456789012345678901234567890123456789012345678'),
},
*/
/*
// GoogleLDAPAuth (optimized for google auth)
authentication: 'GoogleLDAPAuth',
authenticationOptions: {
...
...
@@ -32,6 +35,7 @@ module.exports = {
certFile: 'ldap.gsuite.crt',
},
},
*/
/** LDAP AUTH
authentication: 'LDAPAuth',
...
...
@@ -68,10 +72,8 @@ module.exports = {
}
*/
/** HTTP AUTH
authentication
:
'
HTTPAuth
'
,
authenticationOptions
:
{
url: 'https://my-website.com/api/backend-login'
url
:
process
.
env
.
AUTH_URL
||
'
https://my-website.com/api/backend-login
'
}
*/
};
src/app.ts
View file @
c31a1a91
...
...
@@ -57,20 +57,24 @@ console.log(`Auth Config: ${JSON.stringify(argv.authenticationOptions, undefined
const
radiusService
=
new
RadiusService
(
config
.
secret
,
authentication
);
server
.
on
(
'
message
'
,
async
(
msg
,
rinfo
)
=>
{
const
response
=
await
radiusService
.
handleMessage
(
msg
);
try
{
const
response
=
await
radiusService
.
handleMessage
(
msg
);
if
(
response
)
{
server
.
sendToClient
(
response
.
data
,
rinfo
.
port
,
rinfo
.
address
,
(
err
,
_bytes
)
=>
{
if
(
err
)
{
console
.
log
(
'
Error sending response to
'
,
rinfo
);
}
},
response
.
expectAcknowledgment
);
if
(
response
)
{
server
.
sendToClient
(
response
.
data
,
rinfo
.
port
,
rinfo
.
address
,
(
err
,
_bytes
)
=>
{
if
(
err
)
{
console
.
log
(
'
Error sending response to
'
,
rinfo
);
}
},
response
.
expectAcknowledgment
);
}
}
catch
(
e
)
{
console
.
error
(
`Error handling request:
${
e
.
toString
()}
`
);
}
});
...
...
src/auth/HTTPAuth.ts
View file @
c31a1a91
...
...
@@ -13,25 +13,30 @@ export class HTTPAuth implements IAuthentication {
}
async
authenticate
(
username
:
string
,
password
:
string
)
{
const
result
=
await
axios
.
post
(
this
.
url
,
{
username
,
password
,
},
{
validateStatus
(
status
)
{
return
status
>=
200
&&
status
<
500
;
try
{
const
result
=
await
axios
.
post
(
this
.
url
,
{
username
,
password
,
},
{
validateStatus
(
status
)
{
return
status
>=
200
&&
status
<
500
;
},
}
);
if
(
result
.
status
<
300
)
{
return
true
;
}
);
if
(
result
.
status
===
200
)
{
return
true
;
console
.
log
(
`HTTP authentication failed, response code:
${
result
.
status
}
`
);
return
false
;
}
catch
(
e
)
{
console
.
log
(
`HTTP authentication errored:
${
e
.
toString
()}
`
);
return
false
;
}
console
.
log
(
`HTTP authentication failed, response code:
${
result
.
status
}
`
);
return
false
;
}
}
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