linagora / esn-frontend-common-libs

Common ground for OpenPaaS frontend (https://open-paas.org)
Other
4 stars 12 forks source link

As a devops I want to be able to use run time configuration #193

Closed fabienmoyon closed 3 years ago

fabienmoyon commented 3 years ago

 CURRENTLY

For now at the run time ,we support to configure the AUTH_PROVIDER_SETTINGS in to the openpaas.js.

GOAL

The goal is to able to use run time configuration

EXPECTED

Like it was done for the AUTH_PROVIDER_SETTINGS we need also to have the OPENPAAS_URL, the BASE_HREF and the APP_GRID_ITEMS in to the openpaas.js

LINKS

https://github.com/OpenPaaS-Suite/esn-frontend-inbox/blob/f96115397f368dc7b71101ba0bbf2fefe31d1c18/webpack.commons.js

https://github.com/OpenPaaS-Suite/esn-frontend-common-libs/blob/1131687b39fb989a5b41fafac2b5c8e99ac50cda/src/frontend/js/modules/auth/client.js maintenant

https://github.com/OpenPaaS-Suite/openpaas-front

tanandy commented 3 years ago

ex:

window.openpaas = {
  //AUTH_PROVIDER: 'basic'
  AUTH_PROVIDER: 'oidc',
  OPENPAAS_URL: 'http://backend.open-paas.org.local',
  BASE_HREF: '/inbox/',
  APP_GRID_ITEMS: '[{ "name": "Calendar", "url": "/calendar/" }, { "name": "Contacts", "url": "/contacts/" }, { "name": "Inbox", "url": "/inbox/" }]',
  AUTH_PROVIDER_SETTINGS: {
  authority: 'http://auth.open-paas.org.local/auth/realms/master',
  client_id: 'openpaas',
  redirect_uri: 'http://inbox.open-paas.org.local/inbox/#/auth/oidc/callback',
  silent_redirect_uri: 'http://inbox.open-paas.org.local/inbox/auth/silent-renew.html',
  post_logout_redirect_uri: 'http://inbox.open-paas.org.local/',
  response_type: 'code',
  scope: 'openid email profile'
  }
};
alagane commented 3 years ago

There is a webpack plugin to solve the BASE_HREF (publicPath on webpack) problem. https://www.npmjs.com/package/webpack-dynamic-public-path Since we use webpack ^4.43.0 this should be compatible. We should test it to see if it solves the problem correctly.

fabienmoyon commented 3 years ago

ok so after investigation :

  1. OPENPAAS_URL will be rename by API_BASE_URL in to openpaas.js will be used to overload ESN restangular

  2. BASE_HREF in to openpaas.js will be used to overload base(href=base) script(src="BASE_HREF/env/openpaas.js") and inbox restangular

@renaudboyer, @huy-ta @rezk2ll need also to be done in Calendar module and after done for others SPA (coutact, account and admin)

Second step need also to improve this workflow for script(src="/socket.io/socket.io.js")

@chamerling can you please have a look, told us if we don't miss something and validate what we want to do to be able to use run time configuration

tanandy commented 3 years ago

cc @huy-ta @rezk2ll @tuanlc @renaudboyer

renaudboyer commented 3 years ago

It's ok for the calendar team

tanandy commented 3 years ago

seems we can already use one variable to setup API BASE URL:

https://github.com/OpenPaaS-Suite/esn-frontend-common-libs/blob/1131687b39fb989a5b41fafac2b5c8e99ac50cda/src/frontend/js/modules/http.js#L102

chamerling commented 3 years ago

OPENPAAS_API_URL is already defined and must be used. Please update the doc and the .env samples

tanandy commented 3 years ago

cc @rezk2ll

renaudboyer commented 3 years ago

Static configuration done

Dynamic configuration will be dealt here: #237