Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corps-directory
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fhurtado14
corps-directory
Commits
a9eabb0b
Commit
a9eabb0b
authored
5 months ago
by
Federico Hurtado
Browse files
Options
Downloads
Patches
Plain Diff
Bypass cas authentication when using localhost
parent
ee984cd0
No related branches found
No related tags found
1 merge request
!2
able to bypass cas in localhost
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/.env
+1
-1
1 addition, 1 deletion
backend/.env
backend/config/auth/auth.login.js
+22
-0
22 additions, 0 deletions
backend/config/auth/auth.login.js
with
23 additions
and
1 deletion
backend/.env
+
1
−
1
View file @
a9eabb0b
...
@@ -5,4 +5,4 @@ DB_PASSWORD=corps_db_password
...
@@ -5,4 +5,4 @@ DB_PASSWORD=corps_db_password
DB_NAME=corps_directory_db
DB_NAME=corps_directory_db
PORT=3000
PORT=3000
FRONTEND_URL=localhost:8080
FRONTEND_URL=http://localhost:8080
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/config/auth/auth.login.js
+
22
−
0
View file @
a9eabb0b
...
@@ -9,6 +9,28 @@ const casLogin = function (req, res, next) {
...
@@ -9,6 +9,28 @@ const casLogin = function (req, res, next) {
// hard-coded for now.
// hard-coded for now.
const
JWT_SECRET
=
"
secret_key
"
;
const
JWT_SECRET
=
"
secret_key
"
;
// if on localhost, accept the authentication and give a key
console
.
log
(
"
user:
"
,
process
.
env
.
DB_USER
);
if
(
process
.
env
.
DB_USER
===
"
corps_directory_dev
"
)
{
// payload for the JWT token
const
payload
=
{
id
:
1
,
role
:
"
admin
"
,
username
:
"
localhostuser
"
,
};
// sign the token with secret key
const
token
=
jwt
.
sign
(
payload
,
JWT_SECRET
,
{
expiresIn
:
"
1h
"
});
console
.
log
(
"
sending token for use in localhost
"
);
console
.
log
(
"
Frontend:
"
,
process
.
env
.
FRONTEND_URL
);
res
.
redirect
(
`
${
process
.
env
.
FRONTEND_URL
}
/home?token=
${
token
}
`
);
return
;
}
// call the authenticate function with CAS
// call the authenticate function with CAS
passport
.
authenticate
(
"
cas
"
,
function
(
err
,
user
,
info
)
{
passport
.
authenticate
(
"
cas
"
,
function
(
err
,
user
,
info
)
{
if
(
err
)
{
if
(
err
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment