@things-factory/auth-base 6.2.27 → 6.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/config.development.js +25 -4
- package/config/config.production.js +25 -4
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/middlewares/jwt-authenticate-middleware.js +7 -0
- package/dist-server/middlewares/jwt-authenticate-middleware.js.map +1 -1
- package/dist-server/router/auth-refresh-token-router.d.ts +1 -0
- package/dist-server/router/auth-refresh-token-router.js +21 -0
- package/dist-server/router/auth-refresh-token-router.js.map +1 -0
- package/dist-server/service/user/user.js +2 -1
- package/dist-server/service/user/user.js.map +1 -1
- package/dist-server/templates/account-unlock-email.js +2 -1
- package/dist-server/templates/account-unlock-email.js.map +1 -1
- package/dist-server/templates/invitation-email.js +2 -1
- package/dist-server/templates/invitation-email.js.map +1 -1
- package/dist-server/templates/reset-password-email.js +2 -1
- package/dist-server/templates/reset-password-email.js.map +1 -1
- package/dist-server/templates/verification-email.js +2 -1
- package/dist-server/templates/verification-email.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/middlewares/jwt-authenticate-middleware.ts +13 -1
- package/server/service/user/user.ts +3 -1
- package/server/templates/account-unlock-email.ts +2 -1
- package/server/templates/invitation-email.ts +2 -1
- package/server/templates/reset-password-email.ts +2 -1
- package/server/templates/verification-email.ts +2 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/auth-base",
|
3
|
-
"version": "6.2.
|
3
|
+
"version": "6.2.31",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "dist-client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -30,10 +30,10 @@
|
|
30
30
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
31
31
|
},
|
32
32
|
"dependencies": {
|
33
|
-
"@things-factory/email-base": "^6.2.
|
33
|
+
"@things-factory/email-base": "^6.2.31",
|
34
34
|
"@things-factory/env": "^6.2.27",
|
35
|
-
"@things-factory/i18n-base": "^6.2.
|
36
|
-
"@things-factory/shell": "^6.2.
|
35
|
+
"@things-factory/i18n-base": "^6.2.31",
|
36
|
+
"@things-factory/shell": "^6.2.31",
|
37
37
|
"@things-factory/utils": "^6.2.27",
|
38
38
|
"jsonwebtoken": "^9.0.0",
|
39
39
|
"koa-passport": "^6.0.0",
|
@@ -42,5 +42,5 @@
|
|
42
42
|
"passport-jwt": "^4.0.0",
|
43
43
|
"passport-local": "^1.0.0"
|
44
44
|
},
|
45
|
-
"gitHead": "
|
45
|
+
"gitHead": "0e904fde521867b12fb95fc24f98ca5e6bd53e6e"
|
46
46
|
}
|
@@ -1,13 +1,17 @@
|
|
1
1
|
import passport from 'koa-passport'
|
2
2
|
import { ExtractJwt, Strategy as JWTstrategy } from 'passport-jwt'
|
3
3
|
|
4
|
+
import { config } from '@things-factory/env'
|
5
|
+
|
4
6
|
import { makeVerificationToken } from '../controllers/utils/make-verification-token'
|
5
7
|
import { saveVerificationToken } from '../controllers/utils/save-verification-token'
|
6
8
|
import { User, UserStatus } from '../service/user/user'
|
7
9
|
import { VerificationTokenType } from '../service/verification-token/verification-token'
|
8
|
-
import { clearAccessTokenCookie, getAccessTokenCookie } from '../utils/access-token-cookie'
|
10
|
+
import { clearAccessTokenCookie, getAccessTokenCookie, setAccessTokenCookie } from '../utils/access-token-cookie'
|
9
11
|
import { SECRET } from '../utils/get-secret'
|
10
12
|
|
13
|
+
const sessionExpiryPolicy = config.get('session/expiryPolicy', 'fixed')
|
14
|
+
|
11
15
|
passport.use(
|
12
16
|
new JWTstrategy(
|
13
17
|
{
|
@@ -65,6 +69,14 @@ export async function jwtAuthenticateMiddleware(context, next) {
|
|
65
69
|
} else {
|
66
70
|
context.state.user = userEntity
|
67
71
|
context.state.decodedToken = decoded
|
72
|
+
|
73
|
+
if (sessionExpiryPolicy == 'rolling') {
|
74
|
+
/* To renew the expiry time on each request, a token is issued and the session is updated. */
|
75
|
+
|
76
|
+
const token = await userEntity.sign()
|
77
|
+
setAccessTokenCookie(context, token)
|
78
|
+
}
|
79
|
+
|
68
80
|
await next()
|
69
81
|
}
|
70
82
|
}
|
@@ -28,6 +28,8 @@ import { getDomainsWithPrivilege } from '../../utils/get-user-domains'
|
|
28
28
|
const ORMCONFIG = config.get('ormconfig', {})
|
29
29
|
const DATABASE_TYPE = ORMCONFIG.type
|
30
30
|
|
31
|
+
const sessionExpirySeconds = Number(config.get('session/expirySeconds')) || '7d'
|
32
|
+
|
31
33
|
export enum UserStatus {
|
32
34
|
INACTIVE = 'inactive',
|
33
35
|
ACTIVATED = 'activated',
|
@@ -164,7 +166,7 @@ export class User {
|
|
164
166
|
|
165
167
|
/* signing for jsonwebtoken */
|
166
168
|
async sign(options?) {
|
167
|
-
var { expiresIn =
|
169
|
+
var { expiresIn = sessionExpirySeconds, subdomain } = options || {}
|
168
170
|
|
169
171
|
var user = {
|
170
172
|
id: this.id,
|
@@ -3,10 +3,11 @@ export function getUnlockUserEmailForm({ name, resetUrl }) {
|
|
3
3
|
<html lang="en">
|
4
4
|
<head>
|
5
5
|
<meta charset="utf-8" />
|
6
|
-
|
6
|
+
|
7
7
|
<title>reset password</title>
|
8
8
|
<meta name="description" content="Password Reset" />
|
9
9
|
<meta name="author" content="hatiolab" />
|
10
|
+
<meta name="google" content="notranslate"/>
|
10
11
|
</head>
|
11
12
|
|
12
13
|
<body>
|
@@ -3,10 +3,11 @@ export function getInvitationEmailForm({ email, acceptUrl }) {
|
|
3
3
|
<html lang="en">
|
4
4
|
<head>
|
5
5
|
<meta charset="utf-8" />
|
6
|
-
|
6
|
+
|
7
7
|
<title>Invitation from Operato</title>
|
8
8
|
<meta name="description" content="Invitation" />
|
9
9
|
<meta name="author" content="hatiolab" />
|
10
|
+
<meta name="google" content="notranslate"/>
|
10
11
|
</head>
|
11
12
|
|
12
13
|
<body>
|
@@ -3,10 +3,11 @@ export function getResetPasswordEmailForm({ name, resetUrl }) {
|
|
3
3
|
<html lang="en">
|
4
4
|
<head>
|
5
5
|
<meta charset="utf-8" />
|
6
|
-
|
6
|
+
|
7
7
|
<title>reset password</title>
|
8
8
|
<meta name="description" content="Password Reset" />
|
9
9
|
<meta name="author" content="hatiolab" />
|
10
|
+
<meta name="google" content="notranslate"/>
|
10
11
|
</head>
|
11
12
|
|
12
13
|
<body>
|
@@ -3,10 +3,11 @@ export function getVerificationEmailForm({ name, verifyUrl }) {
|
|
3
3
|
<html lang="en">
|
4
4
|
<head>
|
5
5
|
<meta charset="utf-8" />
|
6
|
-
|
6
|
+
|
7
7
|
<title>Verify your email</title>
|
8
8
|
<meta name="description" content="Email Verification" />
|
9
9
|
<meta name="author" content="hatiolab" />
|
10
|
+
<meta name="google" content="notranslate"/>
|
10
11
|
</head>
|
11
12
|
|
12
13
|
<body>
|