@raketa-cloud/admin 0.0.66 → 0.0.67
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/package.json +1 -1
- package/src/HonoAdapter.js +11 -6
- package/src/buildResourcePath.js +22 -0
- package/src/cloud/RaketaClient.js +10 -5
- package/src/helpers/AuthHelper.js +15 -10
- package/src/index.js +1 -0
- package/src/setupAuthentication.js +8 -2
- package/src/views/layouts/application.ejs +5 -5
package/package.json
CHANGED
package/src/HonoAdapter.js
CHANGED
|
@@ -36,13 +36,17 @@ export default class HonoAdapter extends Adapter {
|
|
|
36
36
|
this.globalConfig = config;
|
|
37
37
|
|
|
38
38
|
// TODO: Pass in a path to redirect to after login?
|
|
39
|
-
setupAuthentication(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
setupAuthentication(
|
|
40
|
+
router,
|
|
41
|
+
{
|
|
42
|
+
remote: {
|
|
43
|
+
domain: "localhost",
|
|
44
|
+
host: "http://localhost:3000",
|
|
45
|
+
cookie_key: "cms-starter-slim",
|
|
46
|
+
},
|
|
44
47
|
},
|
|
45
|
-
|
|
48
|
+
config
|
|
49
|
+
);
|
|
46
50
|
|
|
47
51
|
router.get("/", (c) => {
|
|
48
52
|
return c.redirect("/en");
|
|
@@ -121,6 +125,7 @@ export default class HonoAdapter extends Adapter {
|
|
|
121
125
|
resourceConfig: resourceConfig,
|
|
122
126
|
adminJwt: ctx.authentication.token,
|
|
123
127
|
remoteConfig: { ...this.globalConfig.remoteConfig },
|
|
128
|
+
globalConfig: this.globalConfig,
|
|
124
129
|
};
|
|
125
130
|
|
|
126
131
|
ctx.logger.info(
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default function buildResourcePath({
|
|
2
|
+
prefix_map,
|
|
3
|
+
resource,
|
|
4
|
+
resourceType,
|
|
5
|
+
locale,
|
|
6
|
+
defaultLocale,
|
|
7
|
+
}) {
|
|
8
|
+
const prefix = prefix_map[resourceType];
|
|
9
|
+
|
|
10
|
+
if (!prefix) {
|
|
11
|
+
throw new Error(`Unknown resource type: ${resourceType}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return [
|
|
15
|
+
locale === defaultLocale ? "" : `/${locale}`,
|
|
16
|
+
prefix,
|
|
17
|
+
"/",
|
|
18
|
+
resource.slug,
|
|
19
|
+
]
|
|
20
|
+
.join("")
|
|
21
|
+
.replace("//", "/");
|
|
22
|
+
}
|
|
@@ -96,11 +96,16 @@ export default class RaketaClient {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
query(query, variables = {}) {
|
|
99
|
-
return this.gqlRequest(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
return this.gqlRequest(
|
|
100
|
+
`${this.getConfig().cloud.gateway_url}/dispatch`,
|
|
101
|
+
query,
|
|
102
|
+
variables,
|
|
103
|
+
{
|
|
104
|
+
"x-raketa-project": this.getConfig().cloud.gateway_project,
|
|
105
|
+
"x-raketa-service": this.getConfig().cloud.dxp_service_private,
|
|
106
|
+
"x-raketa-identity": this.token,
|
|
107
|
+
}
|
|
108
|
+
);
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
formatErrors(errors, generalErrorTo = null) {
|
|
@@ -26,18 +26,23 @@ const AuthHelper = {
|
|
|
26
26
|
return false;
|
|
27
27
|
},
|
|
28
28
|
|
|
29
|
-
getGoogleURL: (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
getGoogleURL: ({
|
|
30
|
+
gateway_url,
|
|
31
|
+
gateway_project,
|
|
32
|
+
gateway_user_pool,
|
|
33
|
+
auth_callback_url,
|
|
34
|
+
}) => {
|
|
35
|
+
if (
|
|
36
|
+
[
|
|
37
|
+
gateway_url,
|
|
38
|
+
gateway_project,
|
|
39
|
+
gateway_user_pool,
|
|
40
|
+
auth_callback_url,
|
|
41
|
+
].join() === ""
|
|
42
|
+
)
|
|
38
43
|
throw new Error("Invalid ENVs for authentication configuration");
|
|
39
44
|
|
|
40
|
-
return `${
|
|
45
|
+
return `${gateway_url}/users/auth/${gateway_project}/${gateway_user_pool}/google?return_to=${auth_callback_url}`;
|
|
41
46
|
},
|
|
42
47
|
};
|
|
43
48
|
|
package/src/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { default as routeSettings } from "./routeSettings";
|
|
|
11
11
|
export { default as setupCloud } from "./setupCloud";
|
|
12
12
|
export { default as routeStandard } from "./routeStandard";
|
|
13
13
|
export { default as routeCategoriesModule } from "./routeCategoriesModule";
|
|
14
|
+
export { default as buildResourcePath } from "./buildResourcePath";
|
|
14
15
|
|
|
15
16
|
export { default as RaketaClient } from "./cloud/RaketaClient";
|
|
16
17
|
export { default as Redirects } from "./cloud/Redirects";
|
|
@@ -9,7 +9,7 @@ function getAuthBearer(c) {
|
|
|
9
9
|
return authHeader.replace("Bearer ", "");
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const setupAuthentication = (app, opts) => {
|
|
12
|
+
const setupAuthentication = (app, opts, config) => {
|
|
13
13
|
app.use(async (c, next) => {
|
|
14
14
|
const token = getCookie(c, AuthHelper.cookie_key) || getAuthBearer(c);
|
|
15
15
|
|
|
@@ -28,7 +28,13 @@ const setupAuthentication = (app, opts) => {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
app.get("/login", async (c) => {
|
|
31
|
-
const googleURL = AuthHelper.getGoogleURL(
|
|
31
|
+
const googleURL = AuthHelper.getGoogleURL({
|
|
32
|
+
gateway_url: config.cloud.gateway_url,
|
|
33
|
+
gateway_project: config.cloud.gateway_project,
|
|
34
|
+
gateway_user_pool: config.cloud.gateway_user_pool,
|
|
35
|
+
auth_callback_url: config.cloud.auth_callback_url,
|
|
36
|
+
});
|
|
37
|
+
|
|
32
38
|
const templatePath = `${currentPath}/views/_auth/login.ejs`;
|
|
33
39
|
|
|
34
40
|
const rendered = await ejs.renderFile(templatePath, {
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
</head>
|
|
19
19
|
|
|
20
20
|
<script>
|
|
21
|
-
var RAKETA_IMAGES_API_KEY = "<%=
|
|
21
|
+
var RAKETA_IMAGES_API_KEY = "<%= _context.globalConfig.cloud.images_api_key %>";
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
24
|
<script src="https://storage.googleapis.com/cdn-raketa-cloud/js/raketa-image-picker-webcomponent.umd.js"></script>
|
|
25
25
|
|
|
26
26
|
<script>
|
|
27
|
-
var FILE_PICKER_GATEWAY_DISPATCH_URL = "<%=
|
|
28
|
-
var FILE_PICKER_GATEWAY_PROJECT = "<%=
|
|
29
|
-
var FILE_PICKER_DXP_PRIVATE_SERVICE = "<%=
|
|
27
|
+
var FILE_PICKER_GATEWAY_DISPATCH_URL = "<%= _context.globalConfig.cloud.gatway_url %>/dispatch";
|
|
28
|
+
var FILE_PICKER_GATEWAY_PROJECT = "<%= _context.globalConfig.cloud.gateway_project %>";
|
|
29
|
+
var FILE_PICKER_DXP_PRIVATE_SERVICE = "<%= _context.globalConfig.cloud.dxp_service_private %>";
|
|
30
30
|
var FILE_PICKER_JWT_TOKEN = "<%= _context.adminJwt %>";
|
|
31
31
|
</script>
|
|
32
32
|
|
|
@@ -218,4 +218,4 @@
|
|
|
218
218
|
</script>
|
|
219
219
|
</body>
|
|
220
220
|
|
|
221
|
-
</html>
|
|
221
|
+
</html>
|