@Override public AuthHandler addAuthorities(Set<String> authorities) { for (AuthHandler h : handlers) { h.addAuthorities(authorities); } return this; }
@Override public AuthHandler addAuthorities(Set<String> authorities) { for (AuthHandler h : handlers) { h.addAuthorities(authorities); } return this; }
/** * Add a set of required authorities for this auth handler * @param authorities the set of authorities * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.AuthHandler addAuthorities(Set<String> authorities) { delegate.addAuthorities(authorities); return this; }
/** * Add a set of required authorities for this auth handler * @param authorities the set of authorities * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.AuthHandler addAuthorities(Set<String> authorities) { delegate.addAuthorities(authorities); return this; }
@Override public AuthHandler addAuthorities(final Set<String> authorities) { for (AuthHandler h : handlers) { h.addAuthorities(authorities); } return this; }
AuthHandler authHandler = createAuthHandler(authProvider); if (authorities != null) { authHandler.addAuthorities(authorities);
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); }
private void handle(InterceptableRoutingContext context, int orLevelIndex, int andLevelIndex) { // reset context context.clearUser(); context.setNextCallback(null); context.setFailedCallback(null); // prepare routing next of failure behaviours if (andLevelIndex < security.get(orLevelIndex).size() - 1) { context.setNextCallback(() -> handle(context, orLevelIndex, andLevelIndex + 1)); } if (orLevelIndex < security.size() - 1) { context.setFailedCallback(() -> handle(context, orLevelIndex + 1, 0)); } // navigate to the auth provider at given orIndex and andIndex and call it. // if it fails, the context will call the next auth handler at the OR level, or fail or no more are available. // if it succeeds, the context will call the next auth handler at the AND level, or call the next route handler if no more are available. Map<String, List<String>> orSecurityIdentifiers = security.get(orLevelIndex); if (!orSecurityIdentifiers.isEmpty()) { List<String> andSecurityIdentifiers = new ArrayList<>(orSecurityIdentifiers.keySet()); String securityIdentifier = andSecurityIdentifiers.get(andLevelIndex); AuthHandler handler = SwaggerAuthHandlerFactory.this.getAuthHandler(securityIdentifier); if (handler != null) { context.put(SwaggerRouter.AUTH_PROVIDER_NAME_HEADER_KEY, securityIdentifier); handler.addAuthorities(this.authorities).handle(context); } else { context.fail(401); } } else { context.fail(401); } }
AuthHandler authHandler = createAuthHandler(authProvider); if (authorities != null) { authHandler.addAuthorities(authorities);
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); }