Search in sources :

Example 1 with UsernamePasswordAuthProvider

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

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

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