Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoBackendAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Backend
DojoBackendAPI
Commits
66a6f6eb
Commit
66a6f6eb
authored
2 years ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
JWT => Add possibility for no expiry tokens
parent
81a65c52
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ExpressAPI/src/config/Config.ts
+7
-4
7 additions, 4 deletions
ExpressAPI/src/config/Config.ts
ExpressAPI/src/controllers/Session.ts
+1
-1
1 addition, 1 deletion
ExpressAPI/src/controllers/Session.ts
with
8 additions
and
5 deletions
ExpressAPI/src/config/Config.ts
+
7
−
4
View file @
66a6f6eb
...
@@ -9,8 +9,9 @@ class Config {
...
@@ -9,8 +9,9 @@ class Config {
type
:
string
,
host
:
string
,
port
:
number
,
user
:
string
,
password
:
string
,
database
:
string
type
:
string
,
host
:
string
,
port
:
number
,
user
:
string
,
password
:
string
,
database
:
string
};
};
public
readonly
jwtSecretKey
:
string
;
public
jwtConfig
:
{
public
readonly
sessionTimeout
:
number
;
secret
:
string
;
expiresIn
:
number
;
};
public
permissions
:
{
public
permissions
:
{
teachingStaff
:
Array
<
string
>
;
teachingStaff
:
Array
<
string
>
;
...
@@ -33,8 +34,10 @@ class Config {
...
@@ -33,8 +34,10 @@ class Config {
database
:
process
.
env
.
DATABASE_NAME
database
:
process
.
env
.
DATABASE_NAME
};
};
this
.
jwtSecretKey
=
process
.
env
.
JWT_SECRET_KEY
;
this
.
jwtConfig
=
{
this
.
sessionTimeout
=
Number
(
process
.
env
.
SESSION_TIMEOUT
);
secret
:
process
.
env
.
JWT_SECRET_KEY
,
expiresIn
:
Number
(
process
.
env
.
SESSION_TIMEOUT
)
};
this
.
permissions
=
{
this
.
permissions
=
{
teachingStaff
:
JSON
.
parse
(
process
.
env
.
ROLES_WITH_TEACHING_STAFF_PERMISSIONS
)
teachingStaff
:
JSON
.
parse
(
process
.
env
.
ROLES_WITH_TEACHING_STAFF_PERMISSIONS
)
...
...
This diff is collapsed.
Click to expand it.
ExpressAPI/src/controllers/Session.ts
+
1
−
1
View file @
66a6f6eb
...
@@ -40,7 +40,7 @@ class Session {
...
@@ -40,7 +40,7 @@ class Session {
}
}
private
static
getToken
(
profileJson
:
any
):
string
{
private
static
getToken
(
profileJson
:
any
):
string
{
return
profileJson
.
id
===
null
?
null
:
jwt
.
sign
({
profile
:
profileJson
},
Config
.
jwt
SecretKey
,
{
expiresIn
:
Config
.
sessionTimeout
});
return
profileJson
.
id
===
null
?
null
:
jwt
.
sign
({
profile
:
profileJson
},
Config
.
jwt
Config
.
secret
,
Config
.
jwtConfig
.
expiresIn
>
0
?
{
expiresIn
:
Config
.
jwtConfig
.
expiresIn
}
:
{
});
}
}
private
async
getResponse
(
code
:
number
,
data
:
any
,
descriptionOverride
?:
string
):
Promise
<
any
>
{
private
async
getResponse
(
code
:
number
,
data
:
any
,
descriptionOverride
?:
string
):
Promise
<
any
>
{
...
...
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