java - JAX-RS: Authenticate with multiple principals (more than just username) -


using jersey service, elegant method authenticate user more username , password? say, business id, , username principals, , password credential.

i have postgres db users table, same username string can exist multiple business entities. (a unique constraint belongs 2 columns, business id , username together).

i use basic authentication, having client send additional http header business id. how go on here?

now, regarding authorization, how set roles , permissions, if roles created each business entity (each business can define it's own roles , connect permissions.)? permissions static.

does apache shiro (or other pluggable security extension) offer solution in case?

thanks.

you might consider.

  1. implement auth logic in old servlet filter. jax-rs application normal www aplication, filters fits simple authorization mechanism.

  2. jax-rs interceptors (preprocessinterceptor) can implement auth logic need (calling database, etc.) "more idiomatic" while working jax-rs.

  3. use spring security. option if ready learn little of spring framework. spring security provides full featured authentication , access control mechanism, can implement whatever need. note rest of application not neeed use spring.

  4. you might use cdi decorators (example) implement auth logic, sort of exotic given still low cdi adoption.

personaly go 1. or 2, simple cases , 3 more advanced.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -