gawati / gawati-portal-ui

Version 2 of the gawati portal
GNU Affero General Public License v3.0
0 stars 0 forks source link

KeyCloak: Middleware Authentication & Authorizing services #57

Closed kohsah closed 6 years ago

kohsah commented 6 years ago

Currently various services are called by portal-ui. These are all unauthenticated, since by default users are unauthenticated in portal-ui. However, when users log-in they get authenticated and as a result get assigned a role (or multiple roles) .

In this context when services are called we need to be able to distinguish at the service end whether the user making the request to the service is authorized to do so or not, and whether the action being done by the user is allowed for that user (role).

Currently all services in portal-ui are mapped under the following root path:

Most services on the portal are expected to run as public access services (i.e. unautenticated), some services will likely be authenticated. e.g. for paid content , for registering for notifications etc. Such services will be authenticated via a middleware implemented on node-js which will broker the requests to the underlying service requiring authentication.

We propose running such authenticated services under the /gwa root path. The middleware authentication / authorizing layer will query keycloak for token validity and verify credentials submitted by the user before forwarding requests to the authenticated service.

kohsah commented 6 years ago

This has been implemented, its an express js middle-ware that introspects the authentication token and generates a failure if the user isnt permitted. Needs to be explicitly applied to specific routes. : https://github.com/gawati/gawati-auth-middleware

ccsmart commented 6 years ago

We might try to advertise this one upstream to possibly get some visibility / support.

kohsah commented 6 years ago

@ccsmart certainly, need to add some documentation. its published on npm : https://www.npmjs.com/package/gawati-auth-middleware