/** * Sets whether the 'secure' flag should be set for the session cookie. When set * this flag instructs browsers to only send the cookie over HTTPS. Note that * this will probably stop your sessions working if used without HTTPS (e.g. in * development). * @param secure true to set the secure flag on the cookie * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.SessionHandler setCookieSecureFlag(boolean secure) { delegate.setCookieSecureFlag(secure); return this; }
/** * Sets whether the 'secure' flag should be set for the session cookie. When set * this flag instructs browsers to only send the cookie over HTTPS. Note that * this will probably stop your sessions working if used without HTTPS (e.g. in * development). * @param secure true to set the secure flag on the cookie * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.SessionHandler setCookieSecureFlag(boolean secure) { delegate.setCookieSecureFlag(secure); return this; }
@Test public void testSessionCookieSecureFlagAndHttpOnlyFlags() throws Exception { router.route().handler(CookieHandler.create()); router.route().handler(SessionHandler.create(store).setCookieSecureFlag(true).setCookieHttpOnlyFlag(true)); router.route().handler(rc -> rc.response().end()); testRequest(HttpMethod.GET, "/", null, resp -> { String setCookie = resp.headers().get("set-cookie"); assertTrue(setCookie.contains("; Secure")); assertTrue(setCookie.contains("; HTTPOnly")); }, 200, "OK", null); }
@Test public void testSessionCookieSecureFlag() throws Exception { router.route().handler(CookieHandler.create()); router.route().handler(SessionHandler.create(store).setCookieSecureFlag(true)); router.route().handler(rc -> rc.response().end()); testRequest(HttpMethod.GET, "/", null, resp -> { String setCookie = resp.headers().get("set-cookie"); assertTrue(setCookie.contains("; Secure")); }, 200, "OK", null); }
private void addSessionHandler(Vertx vertx, Router router) { SessionStore sessionStore = clustered ? ClusteredSessionStore.create(vertx) : LocalSessionStore .create(vertx); router.route().handler(CookieHandler.create()); router.route().handler(SessionHandler .create(sessionStore) .setCookieHttpOnlyFlag(true) .setCookieSecureFlag(true) ); } }
@Test public void testSessionCookieSecureFlagAndHttpOnlyFlags() throws Exception { router.route().handler(CookieHandler.create()); router.route().handler(SessionHandler.create(store).setCookieSecureFlag(true).setCookieHttpOnlyFlag(true)); router.route().handler(rc -> rc.response().end()); testRequest(HttpMethod.GET, "/", null, resp -> { String setCookie = resp.headers().get("set-cookie"); assertTrue(setCookie.contains("; Secure")); assertTrue(setCookie.contains("; HTTPOnly")); }, 200, "OK", null); }
@Test public void testSessionCookieSecureFlag() throws Exception { router.route().handler(CookieHandler.create()); router.route().handler(SessionHandler.create(store).setCookieSecureFlag(true)); router.route().handler(rc -> rc.response().end()); testRequest(HttpMethod.GET, "/", null, resp -> { String setCookie = resp.headers().get("set-cookie"); assertTrue(setCookie.contains("; Secure")); }, 200, "OK", null); }