Search in sources :

Example 1 with ChainAuthHandler

use of io.vertx.ext.web.handler.ChainAuthHandler in project hono by eclipse.

the class LoraProtocolAdapter method setupAuthorization.

private void setupAuthorization(final Router router) {
    final ChainAuthHandler authHandler = ChainAuthHandler.any();
    authHandler.add(new X509AuthHandler(new TenantServiceBasedX509Authentication(getTenantClient(), tracer), Optional.ofNullable(clientCertAuthProvider).orElseGet(() -> new X509AuthProvider(getCredentialsClient(), tracer)), this::handleBeforeCredentialsValidation));
    authHandler.add(new HonoBasicAuthHandler(Optional.ofNullable(usernamePasswordAuthProvider).orElseGet(() -> new UsernamePasswordAuthProvider(getCredentialsClient(), tracer)), getConfig().getRealm(), this::handleBeforeCredentialsValidation));
    router.route().handler(authHandler);
}
Also used : HonoBasicAuthHandler(org.eclipse.hono.adapter.http.HonoBasicAuthHandler) TenantServiceBasedX509Authentication(org.eclipse.hono.adapter.auth.device.TenantServiceBasedX509Authentication) X509AuthHandler(org.eclipse.hono.adapter.http.X509AuthHandler) UsernamePasswordAuthProvider(org.eclipse.hono.adapter.auth.device.UsernamePasswordAuthProvider) X509AuthProvider(org.eclipse.hono.adapter.auth.device.X509AuthProvider) ChainAuthHandler(io.vertx.ext.web.handler.ChainAuthHandler)

Example 2 with ChainAuthHandler

use of io.vertx.ext.web.handler.ChainAuthHandler in project vertx-zero by silentbalanceyh.

the class WallAxis method create.

/**
 * Two mode for handler supported.
 *
 * @param cliffes
 * @return
 */
private AuthHandler create(final Vertx vertx, final Set<Cliff> cliffes) {
    AuthHandler resultHandler = null;
    if (Values.ONE < cliffes.size()) {
        // 1 < handler
        final ChainAuthHandler chain = ChainAuthHandler.create();
        Observable.fromIterable(cliffes).map(item -> this.bolt.mount(vertx, item)).subscribe(chain::append);
        resultHandler = chain;
    } else {
        // 1 = handler
        if (!cliffes.isEmpty()) {
            final Cliff cliff = cliffes.iterator().next();
            resultHandler = this.bolt.mount(vertx, cliff);
        }
    }
    return resultHandler;
}
Also used : AuthHandler(io.vertx.ext.web.handler.AuthHandler) ChainAuthHandler(io.vertx.ext.web.handler.ChainAuthHandler) AuthHandler(io.vertx.ext.web.handler.AuthHandler) LocalSessionStore(io.vertx.ext.web.sstore.LocalSessionStore) Cliff(io.vertx.up.atom.secure.Cliff) ChainAuthHandler(io.vertx.ext.web.handler.ChainAuthHandler) Vertx(io.vertx.core.Vertx) Router(io.vertx.ext.web.Router) Set(java.util.Set) AuthenticateEndurer(io.vertx.up.web.failure.AuthenticateEndurer) TreeSet(java.util.TreeSet) Bolt(io.vertx.up.rs.secure.Bolt) Axis(io.vertx.up.rs.Axis) Values(io.vertx.zero.eon.Values) SessionHandler(io.vertx.ext.web.handler.SessionHandler) Orders(io.vertx.up.eon.Orders) ZeroAnno(io.vertx.up.web.ZeroAnno) Observable(io.reactivex.Observable) Cliff(io.vertx.up.atom.secure.Cliff) ChainAuthHandler(io.vertx.ext.web.handler.ChainAuthHandler)

Example 3 with ChainAuthHandler

use of io.vertx.ext.web.handler.ChainAuthHandler in project hono by eclipse.

the class VertxBasedHttpProtocolAdapter method addRoutes.

@Override
protected void addRoutes(final Router router) {
    if (getConfig().isAuthenticationRequired()) {
        final ChainAuthHandler authHandler = ChainAuthHandler.any();
        authHandler.add(new X509AuthHandler(new TenantServiceBasedX509Authentication(getTenantClient(), tracer), Optional.ofNullable(clientCertAuthProvider).orElseGet(() -> new X509AuthProvider(getCredentialsClient(), tracer)), this::handleBeforeCredentialsValidation));
        authHandler.add(new HonoBasicAuthHandler(Optional.ofNullable(usernamePasswordAuthProvider).orElseGet(() -> new UsernamePasswordAuthProvider(getCredentialsClient(), tracer)), getConfig().getRealm(), this::handleBeforeCredentialsValidation));
        addTelemetryApiRoutes(router, authHandler);
        addEventApiRoutes(router, authHandler);
        addCommandResponseRoutes(CommandConstants.COMMAND_ENDPOINT, router, authHandler);
    } else {
        log.warn("device authentication has been disabled");
        log.warn("any device may publish data on behalf of all other devices");
        addTelemetryApiRoutes(router, null);
        addEventApiRoutes(router, null);
        addCommandResponseRoutes(CommandConstants.COMMAND_ENDPOINT, router, null);
    }
}
Also used : HonoBasicAuthHandler(org.eclipse.hono.adapter.http.HonoBasicAuthHandler) TenantServiceBasedX509Authentication(org.eclipse.hono.adapter.auth.device.TenantServiceBasedX509Authentication) X509AuthHandler(org.eclipse.hono.adapter.http.X509AuthHandler) UsernamePasswordAuthProvider(org.eclipse.hono.adapter.auth.device.UsernamePasswordAuthProvider) X509AuthProvider(org.eclipse.hono.adapter.auth.device.X509AuthProvider) ChainAuthHandler(io.vertx.ext.web.handler.ChainAuthHandler)

Example 4 with ChainAuthHandler

use of io.vertx.ext.web.handler.ChainAuthHandler in project hono by eclipse.

the class SigfoxProtocolAdapter method setupAuthorization.

private void setupAuthorization(final Router router) {
    final ChainAuthHandler authHandler = ChainAuthHandler.any();
    authHandler.add(new HonoBasicAuthHandler(Optional.ofNullable(this.usernamePasswordAuthProvider).orElseGet(() -> new UsernamePasswordAuthProvider(getCredentialsClient(), this.tracer)), getConfig().getRealm(), this::handleBeforeCredentialsValidation));
    router.route().handler(authHandler);
}
Also used : HonoBasicAuthHandler(org.eclipse.hono.adapter.http.HonoBasicAuthHandler) UsernamePasswordAuthProvider(org.eclipse.hono.adapter.auth.device.UsernamePasswordAuthProvider) ChainAuthHandler(io.vertx.ext.web.handler.ChainAuthHandler)

Aggregations

ChainAuthHandler (io.vertx.ext.web.handler.ChainAuthHandler)4 UsernamePasswordAuthProvider (org.eclipse.hono.adapter.auth.device.UsernamePasswordAuthProvider)3 HonoBasicAuthHandler (org.eclipse.hono.adapter.http.HonoBasicAuthHandler)3 TenantServiceBasedX509Authentication (org.eclipse.hono.adapter.auth.device.TenantServiceBasedX509Authentication)2 X509AuthProvider (org.eclipse.hono.adapter.auth.device.X509AuthProvider)2 X509AuthHandler (org.eclipse.hono.adapter.http.X509AuthHandler)2 Observable (io.reactivex.Observable)1 Vertx (io.vertx.core.Vertx)1 Router (io.vertx.ext.web.Router)1 AuthHandler (io.vertx.ext.web.handler.AuthHandler)1 SessionHandler (io.vertx.ext.web.handler.SessionHandler)1 LocalSessionStore (io.vertx.ext.web.sstore.LocalSessionStore)1 Cliff (io.vertx.up.atom.secure.Cliff)1 Orders (io.vertx.up.eon.Orders)1 Axis (io.vertx.up.rs.Axis)1 Bolt (io.vertx.up.rs.secure.Bolt)1 ZeroAnno (io.vertx.up.web.ZeroAnno)1 AuthenticateEndurer (io.vertx.up.web.failure.AuthenticateEndurer)1 Values (io.vertx.zero.eon.Values)1 Set (java.util.Set)1