router.route("/private/*").handler(RedirectAuthHandler.create(authProvider, "/loginpage.html"));
router.route("/private/*").handler(RedirectAuthHandler.create(authProvider, "/loginpage.html"));
@Override protected AuthHandler createAuthHandler(AuthProvider authProvider) { return RedirectAuthHandler.create(authProvider); }
@Override protected AuthHandler createAuthHandler(AuthProvider authProvider) { return RedirectAuthHandler.create(authProvider); }
@Override public void setUp() throws Exception { super.setUp(); JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties"); AuthProvider authProvider = ShiroAuth.create(vertx, new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(authConfig)); // create a chain chain = ChainAuthHandler.create(); chain .append(JWTAuthHandler.create(null)) .append(BasicAuthHandler.create(authProvider)) .append(RedirectAuthHandler.create(authProvider)); router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx))); router.route().handler(chain); router.route().handler(ctx -> ctx.response().end()); }
/** * Create a handler * @param authProvider the auth service to use * @param loginRedirectURL the url to redirect the user to * @return the handler */ public static io.vertx.rxjava.ext.web.handler.AuthHandler create(io.vertx.rxjava.ext.auth.AuthProvider authProvider, String loginRedirectURL) { io.vertx.rxjava.ext.web.handler.AuthHandler ret = io.vertx.rxjava.ext.web.handler.AuthHandler.newInstance(io.vertx.ext.web.handler.RedirectAuthHandler.create(authProvider.getDelegate(), loginRedirectURL)); return ret; }
/** * Create a handler * @param authProvider the auth service to use * @param loginRedirectURL the url to redirect the user to * @param returnURLParam the name of param used to store return url information in session * @return the handler */ public static io.vertx.rxjava.ext.web.handler.AuthHandler create(io.vertx.rxjava.ext.auth.AuthProvider authProvider, String loginRedirectURL, String returnURLParam) { io.vertx.rxjava.ext.web.handler.AuthHandler ret = io.vertx.rxjava.ext.web.handler.AuthHandler.newInstance(io.vertx.ext.web.handler.RedirectAuthHandler.create(authProvider.getDelegate(), loginRedirectURL, returnURLParam)); return ret; }
/** * Create a handler * @param authProvider the auth service to use * @return the handler */ public static io.vertx.rxjava.ext.web.handler.AuthHandler create(io.vertx.rxjava.ext.auth.AuthProvider authProvider) { io.vertx.rxjava.ext.web.handler.AuthHandler ret = io.vertx.rxjava.ext.web.handler.AuthHandler.newInstance(io.vertx.ext.web.handler.RedirectAuthHandler.create(authProvider.getDelegate())); return ret; }
/** * Create a handler * @param authProvider the auth service to use * @param loginRedirectURL the url to redirect the user to * @return the handler */ public static io.vertx.rxjava.ext.web.handler.AuthHandler create(io.vertx.rxjava.ext.auth.AuthProvider authProvider, String loginRedirectURL) { io.vertx.rxjava.ext.web.handler.AuthHandler ret = io.vertx.rxjava.ext.web.handler.AuthHandler.newInstance(io.vertx.ext.web.handler.RedirectAuthHandler.create(authProvider.getDelegate(), loginRedirectURL)); return ret; }
/** * Create a handler * @param authProvider the auth service to use * @return the handler */ public static io.vertx.rxjava.ext.web.handler.AuthHandler create(io.vertx.rxjava.ext.auth.AuthProvider authProvider) { io.vertx.rxjava.ext.web.handler.AuthHandler ret = io.vertx.rxjava.ext.web.handler.AuthHandler.newInstance(io.vertx.ext.web.handler.RedirectAuthHandler.create(authProvider.getDelegate())); return ret; }
/** * Create a handler * @param authProvider the auth service to use * @param loginRedirectURL the url to redirect the user to * @param returnURLParam the name of param used to store return url information in session * @return the handler */ public static io.vertx.rxjava.ext.web.handler.AuthHandler create(io.vertx.rxjava.ext.auth.AuthProvider authProvider, String loginRedirectURL, String returnURLParam) { io.vertx.rxjava.ext.web.handler.AuthHandler ret = io.vertx.rxjava.ext.web.handler.AuthHandler.newInstance(io.vertx.ext.web.handler.RedirectAuthHandler.create(authProvider.getDelegate(), loginRedirectURL, returnURLParam)); return ret; }
private void doLoginCommon(Handler<RoutingContext> handler, Set<String> authorities) throws Exception { router.route().handler(BodyHandler.create()); router.route().handler(CookieHandler.create()); SessionStore store = LocalSessionStore.create(vertx); router.route().handler(SessionHandler.create(store)); router.route().handler(UserSessionHandler.create(authProvider)); AuthHandler authHandler = RedirectAuthHandler.create(authProvider); if (authorities != null) { authHandler.addAuthorities(authorities); } router.route("/protected/*").handler(authHandler); router.route("/protected/somepage").handler(handler); String loginHTML = createloginHTML(); router.route("/loginpage").handler(rc -> rc.response().putHeader("content-type", "text/html").end(loginHTML)); if (formLoginHandler == null) { formLoginHandler = FormLoginHandler.create(authProvider); } router.route("/login").handler(formLoginHandler); testRequest(HttpMethod.GET, "/protected/somepage", null, resp -> { String location = resp.headers().get("location"); assertNotNull(location); assertEquals("/loginpage", location); String setCookie = resp.headers().get("set-cookie"); assertNotNull(setCookie); sessionCookie.set(setCookie); }, 302, "Found", null); testRequest(HttpMethod.GET, "/loginpage", req -> req.putHeader("cookie", sessionCookie.get()), resp -> { }, 200, "OK", loginHTML); }
router.route().handler(SessionHandler.create(store)); router.route().handler(UserSessionHandler.create(authProvider)); AuthHandler authHandler = RedirectAuthHandler.create(authProvider);
@Override public void setUp() throws Exception { super.setUp(); JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties"); AuthProvider authProvider = ShiroAuth.create(vertx, new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(authConfig)); // create a chain chain = ChainAuthHandler.create(); chain .append(JWTAuthHandler.create(null)) .append(BasicAuthHandler.create(authProvider)) .append(RedirectAuthHandler.create(authProvider)); router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx))); router.route().handler(chain); router.route().handler(ctx -> ctx.response().end()); }
private void doLoginCommon(Handler<RoutingContext> handler, Set<String> authorities) throws Exception { router.route().handler(BodyHandler.create()); router.route().handler(CookieHandler.create()); SessionStore store = LocalSessionStore.create(vertx); router.route().handler(SessionHandler.create(store)); router.route().handler(UserSessionHandler.create(authProvider)); AuthHandler authHandler = RedirectAuthHandler.create(authProvider); if (authorities != null) { authHandler.addAuthorities(authorities); } router.route("/protected/*").handler(authHandler); router.route("/protected/somepage").handler(handler); String loginHTML = createloginHTML(); router.route("/loginpage").handler(rc -> rc.response().putHeader("content-type", "text/html").end(loginHTML)); if (formLoginHandler == null) { formLoginHandler = FormLoginHandler.create(authProvider); } router.route("/login").handler(formLoginHandler); testRequest(HttpMethod.GET, "/protected/somepage", null, resp -> { String location = resp.headers().get("location"); assertNotNull(location); assertEquals("/loginpage", location); String setCookie = resp.headers().get("set-cookie"); assertNotNull(setCookie); sessionCookie.set(setCookie); }, 302, "Found", null); testRequest(HttpMethod.GET, "/loginpage", req -> req.putHeader("cookie", sessionCookie.get()), resp -> { }, 200, "OK", loginHTML); }
router.route().handler(SessionHandler.create(store)); router.route().handler(UserSessionHandler.create(authProvider)); AuthHandler authHandler = RedirectAuthHandler.create(authProvider);