Search in sources :

Example 1 with X509AuthProvider

use of org.eclipse.hono.adapter.auth.device.X509AuthProvider 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 X509AuthProvider

use of org.eclipse.hono.adapter.auth.device.X509AuthProvider 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)

Aggregations

ChainAuthHandler (io.vertx.ext.web.handler.ChainAuthHandler)2 TenantServiceBasedX509Authentication (org.eclipse.hono.adapter.auth.device.TenantServiceBasedX509Authentication)2 UsernamePasswordAuthProvider (org.eclipse.hono.adapter.auth.device.UsernamePasswordAuthProvider)2 X509AuthProvider (org.eclipse.hono.adapter.auth.device.X509AuthProvider)2 HonoBasicAuthHandler (org.eclipse.hono.adapter.http.HonoBasicAuthHandler)2 X509AuthHandler (org.eclipse.hono.adapter.http.X509AuthHandler)2