GAIA-X4PLC-AAD / portal

1 stars 2 forks source link

API: Export keycloak config into a keycloak.json (remove hard coded config) #41

Closed ssoerensen closed 1 month ago

ssoerensen commented 11 months ago

src/context/AuthContextProvider.tsx

https://my.msg-david.de/confluence/display/GAIAX/PoC%3A+Authentication+via+Keycloak

devbysp commented 1 month ago

Pull Request

Solution

config-overrides.js

module.exports = override(
  ...

  // Add Webpack alias for Keycloak configuration based on the environment
  (config) => {
    const isProduction = process.env.NODE_ENV === 'production';

    // Define the path to the correct keycloak-config based on the environment
    config.resolve.alias['keycloak-config'] = path.resolve(
      __dirname,
      isProduction
        ? 'src/keycloak-config.prod.json'   // Production environment
        : 'src/keycloak-config.json'        // Development environment
    );

    // Return the modified Webpack config
    return config;
  }
);

src/keycloak-config.json

{
  "config": {
    "realm": "gaia-x",
    "clientId": "portal",
  },
  "initOptions": {
    "onLoad": "check-sso",
    "checkLoginIframe": false,
    "pkceMethod": "S256"
  }
}