server-state / simple-server

Providing a template for a full server-state setup including authentication, server-base, client-base and a few modules
MIT License
0 stars 0 forks source link

Authentication #9

Open pklaschka opened 4 years ago

pklaschka commented 4 years ago

Add capabilities for authentication to allow for restricted access (in the future including roles with different permissions), allowing to secure the actual information (coming from the API) while still serving a Frontend that handles logging in / staying logged in / and so on.

Details of the proposed implementation

  1. Authentication should work using the OAuth 2.0 standard as it's well known, relatively easy to implement and allows for a lot of options in the room of permissions and so on
  2. Authentication should get handled by the client and should use username/password and later possibly an application token (if wanted)
  3. Authentication should be required every time to protect possibly sensitive server information, i.e., tokens should not work for a long time
  4. Possibly worth considering whether it's possible to integrate with "standard" implementations of it so that existing solutions on existing servers could get used when server-state gets integrated instead of used as a standalone solution.
pklaschka commented 4 years ago

I would like to move the actual authentication implementation (OAuth or whatever) to simple-server.

Advantages of this approach

  1. Allowing for custom authentication implementations by end-users, including integrating with already existent solutions in, e.g., the company
  2. Ease of integrating authentication, as adding some external library like passport.js is rather ugly inside a library. This should get managed in the server implementation, which, for us, is the simple-server
  3. Future-proof: Since we then don't make the determination which Auth library to use (except for the simple-server, which just serves as an example that's ready to use), we don't have to make any decisions we might regret later when, e.g., a library stops getting maintained, which, of course, would be a catastrophe regarding vulnerabilities in the authentication system.

Proposed implementation


If accepted (or a modified state, if applicable) shall get added to the https://github.com/server-state/specs repository.


@fussel178 any thoughts?

fussel178 commented 4 years ago

Sounds good. But for example we add a new user dynamically with his own token to check. This updates (i think) isAuthorized. Does the server-base call the new function with the new values?

pklaschka commented 4 years ago

@fussel178 In this case, the new user gets added to a database. isAuthorized verifies a token (or user or other credentials) with this database every time. It is basically the same as handling it inside server-base, but more flexible and easier to achieve...

pklaschka commented 4 years ago

Here a small sequence diagram (not really up to UML specs, but who cares :laughing:): sequence diagram

server-base Authentication

pklaschka commented 4 years ago

Adding it to the specifications is in progress with server-state/specs#15. Since this, then, will be more of an issue of server-state/simple-server, I'll transfer the issue...