Re: Is it possible to (easily) have authenticated/non-authenticated versions...
Thanks - that works perfectly for me. I had been returning the guard to fix an earlier problem - but obviously I fixed it in the wrong way. Thanks again for the detailed solution! RB -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Is-it-possible-to-easily-have-authenticated-non-authenticated-versions-tp7557195p7562976.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2961233
Re: Is it possible to (easily) have authenticated/non-authenticated versions...
Hello Richard, I suggest you to update your code as follow: public final Restlet createInboundRoot() { Router rootRouter = new Router(getContext()); Router guardedRouter = new Router(getContext()); // attach your resources, relatively to the root path "/v1" guardedRouter.attach("/test", MyTestResource.class); // This router defines resources without authentication Router router = new Router(getContext()); // attach your resources, relatively to the root path "/v2" router.attach("/test", MyTestResource.class); GaeAuthenticator guard = new GaeAuthenticator(getContext()); guard.setNext(guardedRouter); rootRouter.attach("/v1", guard); rootRouter.attach("/v2", router); return rootRouter; } If you intend to serve the same hierarchy of resources under "/v1", or "/v2", you can define only one router and attach it twice: public final Restlet createInboundRoot() { Router rootRouter = new Router(getContext()); // This router defines resources Router router = new Router(getContext()); // attach your resources router.attach("/test", MyTestResource.class); GaeAuthenticator guard = new GaeAuthenticator(getContext()); guard.setNext(router); rootRouter.attach("/v1", guard); // guarded rootRouter.attach("/v2", router); // not guarded return rootRouter; } Best regards, Thierry Boileau Thanks again for the update - I will continue to work on this, although > right > now I am in the midst of trying to get oAuth2 to work, so it may be a while > before I have a real response. > RB > > -- > View this message in context: > http://restlet-discuss.1400322.n2.nabble.com/Is-it-possible-to-easily-have-authenticated-non-authenticated-versions-tp7557195p7561885.html > Sent from the Restlet Discuss mailing list archive at Nabble.com. > > -- > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2961136 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2961141
RE: Is it possible to (easily) have authenticated/non-authenticated versions...
Thanks again for the update - I will continue to work on this, although right now I am in the midst of trying to get oAuth2 to work, so it may be a while before I have a real response. RB -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Is-it-possible-to-easily-have-authenticated-non-authenticated-versions-tp7557195p7561885.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2961136
RE: Is it possible to (easily) have authenticated/non-authenticated versions...
Yeah the problem IMHO is that you're returning the guard, and the guard knows nothing about your URL scheme if I'm not mistaken. This needs something like router -> guard -> resource instead of guard -> router -> resource. alternatively, there should be an easy way to pattern match a guard to routes. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2961115
RE: Is it possible to (easily) have authenticated/non-authenticated versions...
Thank you for the response... My simplified test code is now: public final Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/v1/", RootServerResource.class); router.attach("/v2/", RootServerResource.class); GaeAuthenticator guard = new GaeAuthenticator(getContext()); router.attach("/v1/", guard, Template.MODE_STARTS_WITH); guard.setNext(router); return guard; } But in the browser, both the paths /v1/ and /v2/ bring up the guard. I am not sure why that happens, but that is what seems to be the result. Thanks for the suggestion (it definitely met the "easy" part of the qualification)! RB -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2960926
RE: Is it possible to (easily) have authenticated/non-authenticated versions...
I haven't tested this so please accept my apologies if it doesn't work. You could use the following form of attach() public Route attach(String pathTemplate, Class targetClass, int matchingMode) and attach your guard with a Template.MODE_STARTS_WITH matchingMode. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2960891
Is it possible to (easily) have authenticated/non-authenticated versions...
As I am working on implementing authentication, I was wondering if I could configure createInboundRoute to attach the GAEAuthenticator guard only to uris of the form /v1/ (to implement authentication) and allow uris of the form /v0/... to pass through without authentication. My code currently is... public final Restlet createInboundRoot() { ... Router router = new Router(getContext()); router.attach("/v1/path", SomeServerResource.class); . router.attach("/v1/otherpath", SomeOtherServerResource.class); GaeAuthenticator guard = new GaeAuthenticator(getContext()); router.attach(VERSION_PATH, guard); guard.setNext(router); return guard; ... I am assuming that what I want is not easily done (that is fine), but I wanted to make sure before moving on (to trying to do hard things or just not doing it). Thanks in advance! RB -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Is-it-possible-to-easily-have-authenticated-non-authenticated-versions-tp7557195.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2960556