Http Basic Authentication

1,069 views
Skip to first unread message

Abhilash Krishnan

unread,
Jul 8, 2015, 1:01:24 PM7/8/15
to ve...@googlegroups.com
Does anyone have an example of Http Server using Http Basic Authentication?

Tim Fox

unread,
Jul 8, 2015, 1:08:02 PM7/8/15
to ve...@googlegroups.com
There are some pretty complete code examples in the vertx-web docs, and tests in the vertx-web test suite.

There's also a vertx-web example for redirect auth (which is slightly more complex)


On 08/07/15 18:01, Abhilash Krishnan wrote:
Does anyone have an example of Http Server using Http Basic Authentication?
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abhilash Krishnan

unread,
Jul 8, 2015, 1:44:47 PM7/8/15
to ve...@googlegroups.com
I checked the vertx-web docs. I am uanble to find complete example for Http Basic Authentication.

Tim Fox

unread,
Jul 8, 2015, 2:18:41 PM7/8/15
to ve...@googlegroups.com
There are complete examples in the test suite

Abhilash Krishnan

unread,
Jul 10, 2015, 7:01:35 AM7/10/15
to ve...@googlegroups.com
Hi,

I am unable to find the git repository for test suite. Can you please share the link?

Arnaud Estève

unread,
Jul 10, 2015, 8:19:08 AM7/10/15
to ve...@googlegroups.com

Abhilash Krishnan

unread,
Jul 10, 2015, 11:06:09 AM7/10/15
to ve...@googlegroups.com
I am using Apache Shiro to authenticate the user. 

                Realm realm = new ShiroRealm();
AuthProvider authProvider = ShiroAuth.create(vertx, realm);
                router.route("/*").handler(BasicAuthHandler.create(authProvider));
router.get("/groups/:groupId").handler(routingContext -> {
boolean isAuthenticated = routingContext.user() != null;
log.info("isAuth? "+isAuthenticated);
});
But when I invoke the connection from Jersey client, it is giving connection refused. How does the authentication happen here?

Paulo Lopes

unread,
Jul 13, 2015, 9:10:25 AM7/13/15
to ve...@googlegroups.com
The way HTTP Basic auth works is as follows:

-> a request is done to a protected resource
<- server responds with 401 and header "WWW-Authenticate"
-> web browser popup shows asking for credentials and new request is done and authorized

Now i think your Jersey client is making a request and gets the 401 so it stops.

If you want it to continue you need to add the header "Authorization" to your request with "username:password" base64 encoded and it should work
Reply all
Reply to author
Forward
0 new messages