UI
This is the frontend for the xpanse project which allows cloud service providers to register managed services to the service catalog and also for end users to deploy services from the service catalog and manage them.
Application Stack
Project is built using ReactJS
library. As we use TypeScript
here, we must ensure all objects have its type explicit
defined.
GUI components are built using antd
library.
Authentication and Authorization
Auth can be controlled by VITE_APP_AUTH_DISABLED
configuration property.
This property is also already configured with appropriate values in different configuration files.
Disable
When we start the UI with the default run command npm run start
,
then the UI will start with no authentication and authorization.
This must be used only for testing and development purposes.
When authentication and authorization is disabled, the test user will then have all roles by default.
OAuth
Authentication and authorization are protected by an OAuth provider.
The default implementation uses Zitadel
as the OAuth provider.
Zitadel Configuration
Before we can start using the UI, we must ensure Zitadel
instance that we consider using,
has all the required configuration. Details can be found here.
For local environments, the access_tokens
are stored with in the browser storage.
This isn't safe, but it's enough for non-production environments and for debugging purposes.
For production environments, we must use Service Workers
which will block anyone from accessing the token.
This can be enabled by making the following configurations.
VITE_APP_AUTH_USE_SERVICE_WORKER_ONLY=true
and the file OidcTrustedDomains.js must be updated with correct information.
oidcDomains
must have the identity provider URL and accessTokenDomains
must have the xpanse API server URL.
If the same must be used with our official docker images, then this file need not be touched. It will be automatically set from the environment variables.
Configuration Properties
All required configuration parameters must be added to .env file here. Even if we don't have a valid default value, we must just add empty value. This file serves as a reference to all required properties.
Since React is compiled to a static app, all configuration values can be seen directly in the browser too. Therefore, no secure configurations such as passwords, keys, etc. must be added here.
Setting Configuration Values
.env Files
- Set values in the .env files.
All default values are set in .env files.
These are automatically loaded by
React
and there is no need to do anything for this to be loaded. - For non-default properties or to override the values is .env, we can set the values in new .env files and load them
using
env-cmd
framework which will automatically inject the variables. Example can be found here
.env files must be used only for default configurations or for development environment configurations values.
Environment Variables
All variables can be overridden by setting environment variables and then running the npm run start
for development or
with docker run
for production.
Getting Configuration Values
We've a custom implementation which reads the configuration from all sources and provides a unified configuration map. Only this must be used for reading configuration from the React app.
Implementation can be found here.
Starting local development server
In the project directory, you can run the below command to start the local development server. This also additionally
needs nodejs
to be installed on the development machine.
No Auth
To start local development server without any auth, use the below command.
$ npm run start