java - How do I expose a User in Cloud Endpoints without passing around the reference? -


in google cloud endpoint can inject custom authenticator , user shown below. expose instance of user service methods in way similar apache shiro's securityutils.getsubject().

i have tried executing userservicefactory.getuserservice().getcurrentuser(), no avail (returns null).

i've implemented annotations perform authentication logic on services , i'd keep separate actual business logic inside services. therefore helpful if retrieve current user belonging request being processed anywhere. i'm implementing without spring security or apache shiro.

is there clean way this?

@apimethod(authenticators = {jwtauthenticator.class}, name = "find", path="foobars", httpmethod = get) public foobar getfoobar(user user, long id) {     // i'd rid of passing user reference     return foobars.get(id, user);  // performs checks on user } 

unfortunately, due way endpoints implemented, not possible cleanly using framework idioms. if stop including user parameters in api methods, authenticators not run in first place, making useless implement authenticator.

if write own auth code independently of endpoints framework, can have static helpers use threadlocal variables store current users, filled through servlet filter or other mechanism.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -