Skip to content

Commit 01a084d

Browse files
committed
FLS-1452 - Remove environmental preview mode
'Preview mode' is an environment variable that is currently set on an environment-by-environment basis. It controls whether we allow passage through the application's 'publishing' endpoints. These publishing endpoints, which support FAB and Form Designer to offer form preview even where forms are not loaded into the Runner cache at app startup, are being removed as part of Live Services' forms re-architecture work. In future, instead of the Runner supporting publishing of arbitrary forms into its cache, all forms will exist in a shared location in Pre-Award, and there will be no practical use case for rendering an arbitrary form. Please note that removing this environment variable does not itself stop forms being previewed, or the preview banner from being rendered when a form is previewed. This is because the preview banner rendering is dependent on the prefix 'preview' being present at the beginning of the form session identifier retrieved from the URL.
1 parent 2a71c0b commit 01a084d

File tree

10 files changed

+3
-48
lines changed

10 files changed

+3
-48
lines changed

.run/RUNNER.run.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<env name="LOG_LEVEL" value="debug" />
3030
<env name="LOGOUT_URL" value="https://authenticator.communities.gov.localhost:3004/sessions/sign-out" />
3131
<env name="MULTIFUND_URL" value="https://frontend.communities.gov.localhost:3008/account" />
32-
<env name="PREVIEW_MODE" value="true" />
3332
<env name="PRIVACY_POLICY_URL" value="https://frontend.communities.gov.localhost:3008/privacy" />
3433
<env name="RSA256_PUBLIC_KEY_BASE64" value="TUlHZk1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTkFEQ0JpUUtCZ1FDdUZBL2xrczcwM2JEeDZYN0duUVIwVlVSOAp6eW8yUEJ6L2E2MVd0TjJCUitYWlV5cjlGaHc4K3E4YVRsbzZ0K2VJa3hENjE4eWpaQkx0cGhZVjUwcTAvOW1OCkk0QStPSURhQ1J0aWd0NDJ4ZUlrbmpydWZ5a280Q0xjV3BFc1dzSkZWSnJnR2xQTHZrMzJHMVJ5WFErOGY1dWsKVmlKbjBKbGlzbWo4bGtzc2pRSURBUUFC" />
3534
<env name="SERVICE_START_PAGE" value="https://frontend.communities.gov.localhost:3008/account" />

copilot/fsd-form-runner-adapter/manifest.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ environments:
8484
dev:
8585
variables:
8686
JWT_AUTH_ENABLED: false
87-
PREVIEW_MODE: true
8887
count:
8988
spot: 2
9089
sidecars:
@@ -107,7 +106,6 @@ environments:
107106
test:
108107
variables:
109108
JWT_AUTH_ENABLED: false
110-
PREVIEW_MODE: true
111109
count:
112110
spot: 2
113111
sidecars:
@@ -130,7 +128,6 @@ environments:
130128
uat:
131129
variables:
132130
JWT_AUTH_ENABLED: false
133-
PREVIEW_MODE: true
134131
count:
135132
range: 2-4
136133
cooldown:
@@ -174,7 +171,6 @@ environments:
174171
SERVICE_START_PAGE: "https://apply.access-funding.communities.gov.uk/account"
175172
ELIGIBILITY_RESULT_URL: "https://apply.access-funding.communities.gov.uk/eligibility-result"
176173
SENTRY_TRACES_SAMPLE_RATE: 0.1
177-
PREVIEW_MODE: false
178174
count:
179175
range: 2-4
180176
cooldown:

docker-compose.e2e.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ services:
2525
- "3009:3009"
2626
environment:
2727
- CHOKIDAR_USEPOLLING=true
28-
- PREVIEW_MODE=true
2928
- LAST_COMMIT
3029
- LAST_TAG
3130
- ACCESSIBILITY_STATEMENT_URL=http://localhost:3008/accessibility_statement
@@ -43,7 +42,6 @@ services:
4342
- SERVICE_START_PAGE=http://localhost:3008/account
4443
- SINGLE_REDIS=true
4544
- FORM_RUNNER_ADAPTER_REDIS_INSTANCE_URI=redis://redis-data:6379
46-
- PREVIEW_MODE=true
4745
- ENABLE_VIRUS_SCAN=true
4846
command: yarn runner start:test
4947
logging:

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ services:
3333
- "3009:3009"
3434
environment:
3535
- CHOKIDAR_USEPOLLING=true
36-
- PREVIEW_MODE=true
3736
- LAST_COMMIT
3837
- LAST_TAG
3938
- JWT_AUTH_ENABLED=false

runner/config/custom-environment-variables.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"authClientAuthUrl": "AUTH_CLIENT_AUTH_URL",
4646
"authClientTokenUrl": "AUTH_CLIENT_TOKEN_URL",
4747
"authClientProfileUrl": "AUTH_CLIENT_PROFILE_URL",
48-
"previewMode": "PREVIEW_MODE",
4948
"enforceCsrf": "ENFORCE_CSRF",
5049
"savePerPage": "SAVE_PER_PAGE",
5150
"awsBucketName": "AWS_BUCKET_NAME",

runner/config/default.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module.exports = {
2121
*/
2222
port: 3009,
2323
env: "development",
24-
previewMode: false,
2524
enforceCsrf: true,
2625
singleRedis: false,
2726
isE2EModeEnabled: false,

runner/config/development.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"isTest": true,
3-
"previewMode": true,
43
"enforceCsrf": false,
54
"env": "development"
65
}

runner/config/test.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"safelist": ["webho.ok"],
33
"isTest": true,
4-
"previewMode": true,
54
"enforceCsrf": false,
65
"initialisedSessionKey": "predictable-key",
76
"env": "test"

runner/src/server/plugins/engine/MainPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export const plugin = {
3232
...LOGGER_DATA,
3333
message: `[FORM-CACHE] number of forms loaded into cache ok[${countOk}] error[${countError}]`
3434
})
35-
new RegisterFormsApi().register(server, options);
35+
new RegisterFormsApi().register(server);
3636
}
3737
};

runner/src/server/plugins/engine/api/RegisterFormsApi.ts

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {RegisterApi} from "./RegisterApi";
22
import {HapiRequest, HapiResponseToolkit, HapiServer} from "../../../types";
3-
import {Options} from "../types/PluginOptions";
43
import {FormPayload} from "../../../../../../digital-form-builder/runner/src/server/plugins/engine/types";
54
// @ts-ignore
65
import Boom from "boom";
@@ -22,11 +21,7 @@ export class RegisterFormsApi implements RegisterApi {
2221
* for its own purposes so if you're changing these endpoints you likely need to go and amend
2322
* the designer too!
2423
*/
25-
register(server: HapiServer, options: Options) {
26-
const {previewMode} = options;
27-
const disabledRouteDetailString =
28-
"A request was made however previewing is disabled. See environment variable details in runner/README.md if this error is not expected.";
29-
24+
register(server: HapiServer) {
3025
server.route({
3126
method: "post",
3227
path: "/publish",
@@ -35,17 +30,8 @@ export class RegisterFormsApi implements RegisterApi {
3530
},
3631
handler: async (request: HapiRequest, h: HapiResponseToolkit) => {
3732
const {adapterCacheService} = request.services([]);
38-
// @ts-ignore
39-
if (!previewMode || previewMode==="false") {
40-
request.logger.error(
41-
[`POST /publish`, "previewModeError"],
42-
disabledRouteDetailString
43-
);
44-
throw Boom.forbidden("Publishing is disabled");
45-
}
4633
const payload = request.payload as FormPayload;
4734
const {id, configuration} = payload;
48-
4935
const parsedConfiguration =
5036
typeof configuration === "string"
5137
? JSON.parse(configuration)
@@ -67,14 +53,6 @@ export class RegisterFormsApi implements RegisterApi {
6753
},
6854
handler: async (request: HapiRequest, h: HapiResponseToolkit) => {
6955
const {id} = request.params;
70-
// @ts-ignore
71-
if (!previewMode || previewMode==="false") {
72-
request.logger.error(
73-
[`GET /published/${id}`, "previewModeError"],
74-
disabledRouteDetailString
75-
);
76-
throw Boom.unauthorized("publishing is disabled");
77-
}
7856
const {adapterCacheService} = request.services([]);
7957
const form = await adapterCacheService.getFormAdapterModel(id, request);
8058
if (!form) {
@@ -93,14 +71,6 @@ export class RegisterFormsApi implements RegisterApi {
9371
},
9472
handler: async (request: HapiRequest, h: HapiResponseToolkit) => {
9573
const {adapterCacheService} = request.services([]);
96-
// @ts-ignore
97-
if (!previewMode || previewMode==="false") {
98-
request.logger.error(
99-
[`GET /published`, "previewModeError"],
100-
disabledRouteDetailString
101-
);
102-
throw Boom.unauthorized("publishing is disabled.");
103-
}
10474
return h
10575
.response(JSON.stringify(await adapterCacheService.getFormConfigurations(request)))
10676
.code(200);
@@ -175,10 +145,7 @@ export class RegisterFormsApi implements RegisterApi {
175145
// @ts-ignore
176146
const state = await adapterCacheService.getState(request);
177147

178-
// @ts-ignore isNotPreview is always false on production
179-
const isNotPreview = !previewMode || previewMode==="false"
180-
181-
if (isNotPreview && !state.callback) {
148+
if (config.copilotEnv == "prod" && !state.callback) {
182149
// if you are here the session likely dropped
183150
request.logger.error(["checkUserSession"], `Session expired ${request.yar.id}`);
184151

0 commit comments

Comments
 (0)