Search code examples
javaauthenticationplayframeworkframeworksassets

Play Framework Java Authentication for Assets


I have a Play application that creates files in the public folder when a user is in session. These files are like working files.

Now, with multiple users working at the same time, I want to restrict a user to his working files and not someone else's.

How do I achieve this ?

What I thought of :

  • Have uuid based file name
  • Store the files in the root of Application and send files to javascript using Java controller
  • Authenticating before using any file

Solution

  • You can use some authentication framework(like SecureSocial or Silhouette) and then manage files from controller. Once you are in SecuredAction or UserAwareAction you can get user identity and access the right file based on some propery of defined identity