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);
}
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;
}
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);
}
}
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);
}
Aggregations