m2ms / fragalysis-frontend

The React, Redux frontend built by webpack
Other
1 stars 1 forks source link

Separate security module for authentication in non-Diamond deployments #1449

Open mwinokan opened 3 months ago

mwinokan commented 3 months ago

@alanbchristie please document/investigate the work required to separate the security module for authentication in non-Diamond deployments.

It is not a priority for the current releases so please spend up to 1 hour documenting this for now.

alanbchristie commented 3 months ago

The current Fragalysis contains modules in the api package (app) that handles communication with the MySQL/ISPyB database to collect the Target Access Strings (TAS) (Proposals/Visits) that a user has been granted access to - validating the user's access to a given Proposal/Visit.

The basic architecture is illustrated in this diagram: -

fragalysis-security-service 001

This has drawbacks: -

  1. Every stack Pod (and a fragalysis deployment can contain more than one Pod) makes validation queries to the MySQL database. Deploy 6 developer stacks, a staging, and production stack and you have (at least) 8 Pods making regular requests to MySQL. Scale the production stack to 4 Pods and then you have 12 Pods making requests.
  2. The validation code is written into the stack, and this makes it difficult to replace the TAS authentication with another type of authenticator - important for others who may want to install the stack and use their own security mechanism using custom logic or other in-house database (e.g. someone who does not use ISPyB).

Extracting the validation logic

We 'extract' the validation logic into a new 'separate' kubernetes deployment (a new Pod, and Service and Ingress): -

fragalysis-security-service 002

This validation logic architecture minimises MySQL connections and makes the security mechanism pluggable because: -

The security Pod would offer authorisation via a simple pre-shared key mechanism (passed in the request header). This is a common and safe approach and also avoids the security Pod from having to understand tokens or the authentication meachanism. Stacks are configured with some new ENV variables: -

They then send a request to the security Pod with a username (and key) and get back a list of TAS strings.

Other options