Skip to content

Commit c26a139

Browse files
Merge pull request #108 from solo-io/charlesthebird/optionsForEnablingAppAuthSections
Added options to configure the app details page auth sections.
2 parents e140a9a + 7125f2f commit c26a139

File tree

6 files changed

+51
-3
lines changed

6 files changed

+51
-3
lines changed

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ ENV VITE_PORTAL_SERVER_URL=$VITE_PORTAL_SERVER_URL \
4949
VITE_CUSTOM_PAGES=$VITE_CUSTOM_PAGES \
5050
VITE_SWAGGER_PREFILL_API_KEY=$VITE_SWAGGER_PREFILL_API_KEY \
5151
VITE_SWAGGER_PREFILL_OAUTH=$VITE_SWAGGER_PREFILL_OAUTH \
52-
VITE_SWAGGER_PREFILL_BASIC=$VITE_SWAGGER_PREFILL_BASIC
52+
VITE_SWAGGER_PREFILL_BASIC=$VITE_SWAGGER_PREFILL_BASIC \
53+
VITE_DEFAULT_APP_AUTH=$VITE_DEFAULT_APP_AUTH
5354

5455
# Copy the server files, (this includes the UI build).
5556
WORKDIR /app
@@ -78,4 +79,5 @@ ENTRYPOINT VITE_PORTAL_SERVER_URL=$VITE_PORTAL_SERVER_URL \
7879
VITE_SWAGGER_PREFILL_API_KEY=$VITE_SWAGGER_PREFILL_API_KEY \
7980
VITE_SWAGGER_PREFILL_OAUTH=$VITE_SWAGGER_PREFILL_OAUTH \
8081
VITE_SWAGGER_PREFILL_BASIC=$VITE_SWAGGER_PREFILL_BASIC \
82+
VITE_DEFAULT_APP_AUTH=$VITE_DEFAULT_APP_AUTH \
8183
node ./bin/www

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ ifneq ($(VITE_SWAGGER_PREFILL_BASIC),)
132132
else ifneq ($(SWAGGER_PREFILL_BASIC),)
133133
UI_ARGS += VITE_SWAGGER_PREFILL_BASIC=$(SWAGGER_PREFILL_BASIC)
134134
endif
135+
#
136+
# DEFAULT_APP_AUTH
137+
ifneq ($(VITE_DEFAULT_APP_AUTH),)
138+
UI_ARGS += VITE_DEFAULT_APP_AUTH=$(VITE_DEFAULT_APP_AUTH)
139+
else ifneq ($(DEFAULT_APP_AUTH),)
140+
UI_ARGS += VITE_DEFAULT_APP_AUTH=$(DEFAULT_APP_AUTH)
141+
endif
142+
135143

136144

137145

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ You can add these environment variables to a `.env.local` file in the `projects/
151151
VITE_SWAGGER_PREFILL_OAUTH='{"clientId": "your-client-id","clientSecret": "your-client-secret-if-required","realm": "your-realms","appName": "your-app-name","scopeSeparator": " ","scopes": "openid profile","additionalQueryStringParams": {"test": "hello"},"useBasicAuthenticationWithAccessCodeGrant": true,"usePkceWithAuthorizationCodeGrant": true}'
152152
```
153153
- `VITE_SWAGGER_PREFILL_BASIC` - Prefills the Swagger UI authorization configuration for a Basic authorization scheme. This can be set using the following format: `'["authDefinitionKey", "username", "password"]'`.
154+
- `VITE_DEFAULT_APP_AUTH` - This controls whether the OAuth and/or API Key sections are shown on the App details page. Can be set to `"OAUTH"`, `"API_KEY"`, or `"ALL"`. Defaults to `"ALL"`.
154155
155156
#### Environment Variables for PKCE Authorization Flow
156157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
changelog:
2+
- type: FIX
3+
issueLink: https://github.com/solo-io/solo-projects/issues/7059
4+
description: >-
5+
Adds an option to configure the UI to show the API Key, OAuth, or both
6+
authorization sections on the App details page.

projects/ui/src/Components/Apps/Details/AppDetailsPageContent.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import {
99
} from "../../../Apis/gg_hooks";
1010
import { Icon } from "../../../Assets/Icons";
1111
import { UtilityStyles } from "../../../Styles/shared/Utility.style";
12+
import {
13+
AppAuthMethod,
14+
defaultAppAuthMethod,
15+
} from "../../../user_variables.tmplr";
1216
import { getTeamDetailsLink } from "../../../Utility/link-builders";
1317
import { BannerHeading } from "../../Common/Banner/BannerHeading";
1418
import { BannerHeadingTitle } from "../../Common/Banner/BannerHeadingTitle";
@@ -77,11 +81,17 @@ export const AppDetailsPageContent = ({ app }: { app: App }) => {
7781
/>
7882
<Box px={"30px"}>
7983
<Flex gap={"30px"} direction={"column"}>
80-
<AppAuthenticationSection app={app} />
84+
{(defaultAppAuthMethod === AppAuthMethod[AppAuthMethod.ALL] ||
85+
defaultAppAuthMethod === AppAuthMethod[AppAuthMethod.OAUTH]) && (
86+
<AppAuthenticationSection app={app} />
87+
)}
8188

8289
<AppMetadataSection app={app} />
8390

84-
<AppApiKeysSection app={app} />
91+
{(defaultAppAuthMethod === AppAuthMethod[AppAuthMethod.ALL] ||
92+
defaultAppAuthMethod === AppAuthMethod[AppAuthMethod.API_KEY]) && (
93+
<AppApiKeysSection app={app} />
94+
)}
8595

8696
{isLoadingSubscriptions || subscriptions === undefined ? (
8797
<Loader />

projects/ui/src/user_variables.tmplr.ts

+21
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,24 @@ export const swaggerPrefillBasic = (() => {
246246
}
247247
: undefined;
248248
})();
249+
250+
/**
251+
* This is optional.
252+
*/
253+
export enum AppAuthMethod {
254+
ALL,
255+
OAUTH,
256+
API_KEY,
257+
}
258+
export const defaultAppAuthMethod = templateString(
259+
"{{ tmplr.defaultAppAuthMethod }}",
260+
insertedEnvironmentVariables?.VITE_DEFAULT_APP_AUTH,
261+
import.meta.env.VITE_DEFAULT_APP_AUTH,
262+
"ALL"
263+
).toUpperCase() as keyof typeof AppAuthMethod;
264+
if (AppAuthMethod[defaultAppAuthMethod] === undefined) {
265+
// eslint-disable-next-line no-console
266+
console.error(
267+
'The value for `VITE_DEFAULT_APP_AUTH` must be: "OAUTH", "ALL", or "API_KEY".'
268+
);
269+
}

0 commit comments

Comments
 (0)