diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index dc0821acb0..37f6442d5e 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -30,7 +30,7 @@ jobs: run: ./start.js & sleep 40 - name: Run Admin Console - run: npx http-server ./build -P http://localhost:8180/ & sleep 30 + run: npx http-server ./build/src/main/resources/admin/resources -P http://localhost:8180/ & sleep 30 - name: Admin Console client run: ./import.js diff --git a/.gitignore b/.gitignore index 559f303c7f..929be65103 100644 --- a/.gitignore +++ b/.gitignore @@ -128,8 +128,9 @@ sketch # snowpack web_modules/ -build/ -.build/ +build/src +build/target +.build/target public/assets/ # server-install diff --git a/build/README.md b/build/README.md new file mode 100644 index 0000000000..7fa5bc5d04 --- /dev/null +++ b/build/README.md @@ -0,0 +1,27 @@ +# Keycloak Admin Console V2 Maven Build + +The Maven build prepares the admin console to be deployed as a theme on the Keycloak server. + +# Build Instructions + +```bash +$> npm run build +$> cd build +$> mvn install +``` + +# Deployment + +The jar created with `mvn install` needs to be deployed to a Maven repository. From there, it will become part of the Keycloak server build. + +For development, you can also just copy the contents of `build/target/classes` to `/themes/keycloak.v2`. Then restart the server. + +# To Run + +Until New Admin Console becomes the default, you will need to start Keycloak server like this: + +```bash +$> bin/standalone.sh -Dprofile.feature.newadmin=enabled +``` + +Then go to `Realm Settings --> Themes` and set Admin Console Theme to `keycloak.v2`. diff --git a/build/pom.xml b/build/pom.xml new file mode 100644 index 0000000000..e57efb428e --- /dev/null +++ b/build/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + org.keycloak + keycloak-admin-ui + 0.0.1-SNAPSHOT + Keycloak Administration UI + + + + Apache License, Version 2.0.0 + http://www.apache.org/licenses/LICENSE-2.0 + repo + + + + + + jboss + https://repository.jboss.org/nexus/content/groups/public/ + + false + + + + + + + + com.google.code.maven-replacer-plugin + maven-replacer-plugin + + + prepare-package + + replace + + + + + target/classes/admin/resources/index.html + target/classes/admin/index.ftl + false + + + src="/_dist_ + src="${resourceUrl}/_dist_ + + + href="./ + href="${resourceUrl}/ + + + <head> + +<head> + <script type="text/javascript"> + var loginRealm = "${loginRealm}"; + var authServerUrl = "${authServerUrl}"; + var authUrl = "${authUrl}"; + var consoleBaseUrl = "${consoleBaseUrl}"; + var resourceUrl = "${resourceUrl}"; + var masterRealm = "${masterRealm}"; + var resourceVersion = "${resourceVersion}"; + </script> + + + + + + + + + + \ No newline at end of file diff --git a/security-admin-console-v2-combined.json b/security-admin-console-v2-combined.json deleted file mode 100644 index d4522ef0ac..0000000000 --- a/security-admin-console-v2-combined.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "clientId": "security-admin-console-v2", - "rootUrl": "", - "adminUrl": "", - "baseUrl": "", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "redirectUris": [ - "/adminv2/*", - "http://localhost:8080/*", - "http://localhost/*" - ], - "webOrigins": [ - "*" - ], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": true, - "implicitFlowEnabled": false, - "directAccessGrantsEnabled": true, - "serviceAccountsEnabled": false, - "publicClient": true, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": { - "saml.assertion.signature": "false", - "saml.force.post.binding": "false", - "saml.multivalued.roles": "false", - "saml.encrypt": "false", - "backchannel.logout.revoke.offline.tokens": "false", - "saml.server.signature": "false", - "saml.server.signature.keyinfo.ext": "false", - "exclude.session.state.from.auth.response": "false", - "backchannel.logout.session.required": "true", - "client_credentials.use_refresh_token": "false", - "saml_force_name_id_format": "false", - "saml.client.signature": "false", - "tls.client.certificate.bound.access.tokens": "false", - "saml.authnstatement": "false", - "display.on.consent.screen": "false", - "saml.onetimeuse.condition": "false" - }, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": true, - "nodeReRegistrationTimeout": -1, - "defaultClientScopes": [ - "web-origins", - "role_list", - "roles", - "profile", - "email" - ], - "optionalClientScopes": [ - "address", - "phone", - "offline_access", - "microprofile-jwt" - ], - "access": { - "view": true, - "configure": true, - "manage": true - } -} \ No newline at end of file diff --git a/snowpack.config.js b/snowpack.config.js index 1791490707..2c46d8b8da 100644 --- a/snowpack.config.js +++ b/snowpack.config.js @@ -9,7 +9,10 @@ module.exports = { "@snowpack/plugin-typescript", ], buildOptions: { - baseUrl: "/adminv2", + baseUrl: "./", clean: true, }, + devOptions: { + out: "build/src/main/resources/admin/resources", // For snowpack 3, "out" goes under buildOptions. + }, }; diff --git a/src/PageHeader.tsx b/src/PageHeader.tsx index b2e9947007..cb7a21d153 100644 --- a/src/PageHeader.tsx +++ b/src/PageHeader.tsx @@ -18,6 +18,7 @@ import { WhoAmIContext } from "./context/whoami/WhoAmI"; import { HelpContext, HelpHeader } from "./components/help-enabler/HelpHeader"; import { Link, useHistory } from "react-router-dom"; import { useAdminClient } from "./context/auth/AdminClient"; +import { resourceUri } from "./util"; export const Header = () => { const adminClient = useAdminClient(); @@ -126,7 +127,7 @@ export const Header = () => { - + ); }; @@ -180,7 +181,7 @@ export const Header = () => { logo={