@nocobase/auth 2.2.7 → 2.2.9
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/lib/actions.js +9 -0
- package/lib/auth.js +6 -3
- package/package.json +7 -7
package/lib/actions.js
CHANGED
|
@@ -89,6 +89,15 @@ const actions = {
|
|
|
89
89
|
ctx.body = filterHiddenFields(ctx, ctx.auth.user);
|
|
90
90
|
await next();
|
|
91
91
|
}, "check"),
|
|
92
|
+
checkLegacyFileAccess: /* @__PURE__ */ __name(async (ctx, next) => {
|
|
93
|
+
var _a;
|
|
94
|
+
if (!ctx.auth.user && ((_a = ctx.state) == null ? void 0 : _a.legacyLocalStoragePublicAccess) !== true) {
|
|
95
|
+
ctx.throw(401, ctx.t("Unauthenticated. Please sign in to continue.", { ns: localeNamespace }));
|
|
96
|
+
}
|
|
97
|
+
ctx.status = 204;
|
|
98
|
+
ctx.withoutDataWrapping = true;
|
|
99
|
+
await next();
|
|
100
|
+
}, "checkLegacyFileAccess"),
|
|
92
101
|
syncCookies: /* @__PURE__ */ __name(async (ctx, next) => {
|
|
93
102
|
ctx.body = await ctx.auth.syncCookies();
|
|
94
103
|
await next();
|
package/lib/auth.js
CHANGED
|
@@ -64,10 +64,13 @@ const _Auth = class _Auth {
|
|
|
64
64
|
this.ctx = ctx;
|
|
65
65
|
}
|
|
66
66
|
async skipCheck() {
|
|
67
|
-
var _a, _b;
|
|
67
|
+
var _a, _b, _c;
|
|
68
68
|
if (this.ctx.skipAuthCheck === true) {
|
|
69
69
|
return true;
|
|
70
70
|
}
|
|
71
|
+
if (((_a = this.ctx.state) == null ? void 0 : _a.legacyFileAccess) === true) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
71
74
|
const { resourceName, actionName } = this.ctx.action;
|
|
72
75
|
const acl = this.ctx.dataSource.acl;
|
|
73
76
|
const isPublic = await acl.allowManager.isPublic(resourceName, actionName, this.ctx);
|
|
@@ -75,11 +78,11 @@ const _Auth = class _Auth {
|
|
|
75
78
|
return true;
|
|
76
79
|
}
|
|
77
80
|
const hasExplicitToken = Boolean(this.ctx.get("Authorization") || this.ctx.query.token);
|
|
78
|
-
if (!hasExplicitToken && this.ctx.app.options.acl === false && ((
|
|
81
|
+
if (!hasExplicitToken && this.ctx.app.options.acl === false && ((_b = this.ctx.state) == null ? void 0 : _b.optionalAuth) !== true) {
|
|
79
82
|
return true;
|
|
80
83
|
}
|
|
81
84
|
const token = this.ctx.getBearerToken();
|
|
82
|
-
if (!token && ((
|
|
85
|
+
if (!token && ((_c = this.ctx.state) == null ? void 0 : _c.optionalAuth) === true) {
|
|
83
86
|
return true;
|
|
84
87
|
}
|
|
85
88
|
if (!token && this.ctx.app.options.acl === false) {
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/auth",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/actions": "2.2.
|
|
10
|
-
"@nocobase/cache": "2.2.
|
|
11
|
-
"@nocobase/database": "2.2.
|
|
12
|
-
"@nocobase/resourcer": "2.2.
|
|
13
|
-
"@nocobase/utils": "2.2.
|
|
9
|
+
"@nocobase/actions": "2.2.9",
|
|
10
|
+
"@nocobase/cache": "2.2.9",
|
|
11
|
+
"@nocobase/database": "2.2.9",
|
|
12
|
+
"@nocobase/resourcer": "2.2.9",
|
|
13
|
+
"@nocobase/utils": "2.2.9",
|
|
14
14
|
"@types/jsonwebtoken": "^9.0.9",
|
|
15
15
|
"jsonwebtoken": "^9.0.2"
|
|
16
16
|
},
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
20
20
|
"directory": "packages/auth"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "82794da75067dd0ae19a9172cea64cb3fb643175"
|
|
23
23
|
}
|