Search code examples
apachecookiessslrestletauthentication

Restlet User Authentication


I'm relatively new to Restlet, so currently I am experimenting with Restlet 2.1, and I want to add user authentication

I am currently using Apache ReverseProxy, and planning to use it as SSL-proxy, so I'll probably encrypt/decrypt on Apache, Restlet will get plain text

I found sayings about using the Restlet ChallengeAuthentication, but can not find it on 2.1 API doc, and since Restlet just updated their site, most Urls are just broken

so it'd be really nice if someone can give me some guide on how to build it or give me a functional link to some examples eg: how do I check for authentication,

how do I detect cookie,

how do I set a secure cookie,

how do I read from that encrypted cookie

also another design question, would I be better off using a function that tries to decrypt the cooke for auth, than actually storing the cookie data in a DB like Redis?

Thanks in advance!


Solution

  • i did authentication using 2.1.2 restlet on GAE. following code may help you how to provide authentication in restlet

    ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext().createChildContext(), ChallengeScheme.HTTP_BASIC,"Your application."); 
    MapVerifier verifier = new MapVerifier();  
    verifier.getLocalSecrets().put(userName, password.toCharArray());
    guard.setVerifier(verifier);
    guard.setNext(this);
    guard.setNext(anyclass.class);
    router.attach("/v1", guard);
    

    and this link http://restlet.org/learn/tutorial/2.1/ for more information about restlet.