This will run on OpenShift as a proxy to your application (which can run on OpenStack).
It takes care of authenticating users using keycloack/OIDC, getting their id, email, name and roles and passing them onto the application running on CLIENT_URL.
If you include an API_URL environment variable, it will also route /api/\*
to the API_URL (with all HTTP possible methods, GET
, POST
, PUT
, ...)
Note: Roles are different from egroups. See here for details.
Environment variables that configure the proxy's execution. You can set those either by running export <VAR>=<VALUE>
or by setting them in an .env
file. See .env_sample
.
Warning To set those variables in Deployment, see here
Environment Variable | Required | Description |
---|---|---|
CLIENT_URL |
true | The URL you want to proxy |
CLIENT_ID |
true | The client id you get from CERN AUTH |
CLIENT_SECRET |
true | The client secret you get from CERN AUTH |
API_URL |
false | If you're also running an API and you want to re-use this proxy, passing this environment variable will redirect all requests that go to the proxy's /api/\* endpoint to the API_URL you provided. |
SERVER_PORT |
false | The port that the proxy listens to, defaults to 8080 |
SERVER_TIMEOUT |
false | The server's timeout in ms, see here |
ENV |
false | The type of environment the proxy is running to. Set to development for extra console messages. |
DEBUG |
false | Accepts a comma-separated list of node modules to enable debugging information for. Example value: http,express:* to enable debugging messages for http and express . |
NODE_ENV |
false | Sets the mode for the express server. Set to development when developing. ` |
Note For deployment, more env vars (such as
NPM_RUN
which lets you specify thenpm run
command to run), specific to the NodeJs s2i image can be found here.
- Make sure you have
node
version 16. - Create an
.env
file in the root of the project, using.env_sample
as a template. -
npm install npm run dev
- While not strictly needed, you will also need to have started the RunRegistry bakend and frontend processes on separate terminals.
- Connect to http://localhost:8080
-
Request a webpage in: CERN Web Services.
Warning Login as user
cmsdqm
. -
Set the type, name of project and description:
-
Go to the
OKD console
as instructed. There, clickTopology
:Warning Login as user
cmsdqm
. -
Right-click and select
Add to Project
->Import from Git
-
Input the git repo url:
-
Select the appropriate
NodeJS
version. As of writing (2023/06), versionnodejs:16-ubi8
is used. -
Edit the routing options, making sure you enter the
Hostname
that you want, withouthttp(s)://
in front. -
Go to the
Administrator
view: -
Click
Networking
->Routes
-
Go to the
Route
that has been created and clickEdit annotations
: -
Add
haproxy.router.openshift.io/ip_whitelist
asKey
and leaving theValue
field empty. -
You can edit the value
haproxy.router.openshift.io/timeout
key to match the timeout value of the server (see env vars). -
[Optional, seems to work correctly even without it] Add an
OidcReturnURI
Resource:-
Go to the Project page on PaaS (e.g. https://paas.cern.ch/k8s/cluster/projects/dev-cmsrunregistry) and click the plus icon, top right:
-
A text editor will open. Paste the following inside:
apiVersion: webservices.cern.ch/v1alpha1 kind: OidcReturnURI metadata: name: dev-cmsrunregistry-return-uri spec: redirectURI: RETURN_URI
Replace
RETURN_URI
with the complete redirect URI to the homepage of your application (e.g.https://dev-cmsrunregistry.web.cern.ch
) -
Click
Create
.
-
-
Note that the deployment is not yet ready to run.
-
Login as
cmsdqm
to the Application Portal. -
Click
Add an Application
: -
Fill in the information as shown:
Make sure you add
cms-dqm-coreteam
as theAdministrator Group
.Click
Create
. -
Click the
SSO Registration
tab and then the plus sign: -
Fill in the SSO Registration form as follows:
Note Make sure you click the green plus sign to add the redirect URL.
-
Click
Submit
:A
client id
and aclient secret
will have been created. Take note of them. -
Back to the
My Applications
page of the portal, click the green edit button next to your registration: -
Repeat for each e-group needed (see the
Permssion
table of the RunRegistry DB for a complete list):
Back to the PaaS project.
-
Go to
Builds
: -
Click on your
BuildConfiguration
: -
Click the
Environment
tab: -
Create an entry for each env variable, as needed (see env vars):
Note The
CLIENT_ID
andCLIENT_SECRET
are the values you noted at step 6 here -
Under
Actions
on the top right, clickStart build
:
In case the proxy seems to be very slow to serve your application, consider
increasing the number of Pods. To do so, go to Developer
, click Topology
,
right-click your proxy and click Edit Pod count
. Increasing it to 3 should be sufficient.