Skip to content

Commit

Permalink
Allow logout redirect URl to be configurable (#5199)
Browse files Browse the repository at this point in the history
* Allow logout redirect URl to be configurable

* Change the default value of the logout URL

* Fix linting error

* Revert createLink change
  • Loading branch information
EricWittmann authored Sep 18, 2024
1 parent 801cb3a commit 23ce2bb
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ private UserInterfaceConfigAuth uiAuthConfig() {
options.put("url", uiConfig.authOidcUrl);
options.put("redirectUri", uiConfig.authOidcRedirectUri);
options.put("clientId", uiConfig.authOidcClientId);
if (!"f5".equals(uiConfig.authOidcLogoutUrl)) {
options.put("logoutUrl", uiConfig.authOidcLogoutUrl);
}
rval.setOptions(options);
}
return rval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class UserInterfaceConfigProperties {
@ConfigProperty(name = "apicurio.ui.auth.oidc.client-id", defaultValue = "apicurio-registry-ui")
@Info(category = "ui", description = "The OIDC clientId", availableSince = "3.0.0")
public String authOidcClientId;
@ConfigProperty(name = "apicurio.ui.auth.oidc.logout-url", defaultValue = "f5")
@Info(category = "ui", description = "The OIDC logout URL", availableSince = "3.0.0")
public String authOidcLogoutUrl;

@ConfigProperty(name = "apicurio.ui.features.read-only.enabled", defaultValue = "false")
@Info(category = "ui", description = "Enabled to set the UI to read-only mode", availableSince = "3.0.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,11 @@ The following {registry} configuration options are available for each component
|`apicurio-registry-ui`
|`3.0.0`
|The OIDC clientId
|`apicurio.ui.auth.oidc.logout-url`
|`string`
|`f5`
|`3.0.0`
|The OIDC logout URL
|`apicurio.ui.auth.oidc.redirect-uri`
|`string`
|`/`
Expand Down
4 changes: 4 additions & 0 deletions ui/.docker-scripts/create-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const AUTH_URL=process.env["REGISTRY_AUTH_URL"];
const AUTH_CLIENT_ID=process.env["REGISTRY_AUTH_CLIENT_ID"];
const AUTH_CLIENT_SCOPES=process.env["REGISTRY_AUTH_CLIENT_SCOPES"];
const AUTH_REDIRECT_URL=process.env["REGISTRY_AUTH_REDIRECT_URL"];
const AUTH_LOGOUT_URL=process.env["REGISTRY_AUTH_LOGOUT_URL"];

const FEATURE_READ_ONLY=process.env["REGISTRY_FEATURE_READ_ONLY"];
const FEATURE_BREADCRUMBS=process.env["REGISTRY_FEATURE_BREADCRUMBS"];
Expand Down Expand Up @@ -77,6 +78,9 @@ if (AUTH_TYPE === "oidc") {
if (AUTH_CLIENT_SCOPES) {
CONFIG.auth.options.scope = AUTH_CLIENT_SCOPES;
}
if (AUTH_LOGOUT_URL) {
CONFIG.auth.options.logoutUrl = AUTH_LOGOUT_URL;
}
}

// Configure features
Expand Down
8 changes: 4 additions & 4 deletions ui/ui-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui/ui-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"vite-tsconfig-paths": "5.0.1"
},
"dependencies": {
"@apicurio/common-ui-components": "2.0.3",
"@apicurio/common-ui-components": "2.0.4",
"@apicurio/apicurio-registry-sdk": "file:../../typescript-sdk",
"@apicurio/data-models": "1.1.27",
"@microsoft/kiota-abstractions": "1.0.0-preview.66",
Expand Down
9 changes: 7 additions & 2 deletions ui/ui-app/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ export const App: FunctionComponent<AppProps> = () => {
type: config.authType() as "none" | "oidc",
options: config.authOptions()
};
if (authConfig.type === "oidc" && (authConfig.options.redirectUri && authConfig.options.redirectUri.startsWith("/"))) {
authConfig.options.redirectUri = window.location.origin + authConfig.options.redirectUri;
if (authConfig.type === "oidc") {
if (authConfig.options.redirectUri && authConfig.options.redirectUri.startsWith("/")) {
authConfig.options.redirectUri = window.location.origin + authConfig.options.redirectUri;
}
if (authConfig.options.logoutUrl && authConfig.options.logoutUrl.startsWith("/")) {
authConfig.options.logoutUrl = window.location.origin + authConfig.options.logoutUrl;
}
}

return (
Expand Down
1 change: 1 addition & 0 deletions ui/ui-app/src/services/useConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export interface OidcJsAuthOptions {
redirectUri: string;
clientId: string;
scope: string;
logoutUrl?: string;
}

// Used when `type=keycloakjs`
Expand Down

0 comments on commit 23ce2bb

Please sign in to comment.