title: Handling UI frontend permissions with API backend
body: <p>I would like to ask for your advice about permissions system architecture. 
  I have web UI as a separate frontend project and API as backend. </p>
  
  <p>On API side permissions are defined for each controller/action as a certain enum with conformity to a number and when I want to create some role - I assign the set of those enums numbers that represent permissions and put them in a JWT token. Later an authorized client sends JWT token in header (Bearer token) and when API is going to invoke certain action - it checks if JWT token contains that enum value (number) that this controller/action is marked. On this side it is easy and working. The good point here is that during authorization we just get the set of ‘numbers’ from the database according to the role and filter access during access itself - so it works fast.</p>
  
  <p>I was thinking of UI logic as of following - user fills login/password at UI side. UI sends credentials to API, API authenticates user, gather subset of permissions + some additional data and encrypts it to a JWT token - UI gets this token and encapsulates it inside cookie (may be + some own information) that is sent to client. So, each time client visits any UI page it sends cookies to UI, and UI gets JWT token from cookie makes API request.</p>
  
  <p>However, in this scenario JWT token is encrypted and UI cannot know the data inside. And moreover, even if it could see data - it would give nothing as well as knowing the set of dynamic roles of API side would not give any information for UI side. Along with encoded ‘numbers’ that are converted to permissions in a real-time only on API side.</p>
  
  <p>The question is how should webUI know if it should render access to admin page for a certain user or not. Or show additional UI options etc.</p>
  
  <p>I think that this question might be trivial, as a lot of systems are split as UI + backend. However I have not found yet any good design explanation regardless.</p>
  
  <p>Hope to get advices from community here. Thanks for ideas.</p>