Encrypting SingleSPA customProps

Viewed 107

How can we encrypt auth token passed to the application from single SPA

singleSpa.registerApplication({name: 'app1',activeWhen,app,customProps: { authToken:"d83jD63UdZ6RS6f70D0" }});
1 Answers

Encryption on a web page is easy, for example, you can use a symmetric encryption algorithm like AES (AES-JS) But the actual question is what is your goal?

  1. Do you want to prevent MITM attacks? use TLS.
  2. Do you want to prevent the client from having access to token? Not possible because he can see request directly.
  3. Do you want to mitigate against XSS attacks? You'll need to store the encryption key somewhere! If it's in memory, then for a few minutes you might be safe if you store it the key in memory but what happens when the tab is closed?

There will be many more security concerns about your usage (judging by code snippet) but you'll need more details in your question.

Related