title: Keycloak authentication for application combined with KEK and DEK?
body: <p>I’m currently in need of the following:</p>
  <ul>
  <li><p>I want to use Keycloak for user authentication</p>
  </li>
  <li><p>I want to use the user’s password to derive an encryption key, preferably using PBKDF2.</p>
  </li>
  <li><p>This key will be used to encrypt/decrypt yet another encryption key, which will be used to encrypt/decrypt data of that user</p>
  </li>
  </ul>
  <p>So, if the user authenticates outside of my own application (keycloak validates the username and password, but the encrypted encryption key, encrypted based on that password, would need to be stored inside my application and outside of Keycloak), how would I go about implementing this?</p>
  <p>So basically I want to implement a DEK (data encryption key) and a KEK (key encryption key), where the DEK is encrypted with the KEK. This KEK would be derived using PBKDF2 but would need to be based on the user’s password to “unlock the key” on authentication.</p>
  <p>However, authentication is in Keycloak, the DEK and KEK are to be used in the external application secured with Keycloak.</p>
  <p>What would be a good strategy to tackle something like this?</p>