Search in sources :

Example 1 with HttpApiMetrics

use of tech.pegasys.web3signer.core.service.http.metrics.HttpApiMetrics in project web3signer by ConsenSys.

the class Eth1Runner method populateRouter.

@Override
protected Router populateRouter(final Context context) {
    final RouterBuilder routerBuilder = context.getRouterBuilder();
    final LogErrorHandler errorHandler = context.getErrorHandler();
    final ArtifactSignerProvider signerProvider = context.getArtifactSignerProvider();
    addPublicKeysListHandler(routerBuilder, signerProvider, ETH1_LIST.name(), context.getErrorHandler());
    final SignerForIdentifier<SecpArtifactSignature> secpSigner = new SignerForIdentifier<>(signerProvider, this::formatSecpSignature, SECP256K1);
    routerBuilder.operation(ETH1_SIGN.name()).handler(new BlockingHandlerDecorator(new Eth1SignForIdentifierHandler(secpSigner, new HttpApiMetrics(context.getMetricsSystem(), SECP256K1)), false)).failureHandler(errorHandler);
    addReloadHandler(routerBuilder, signerProvider, RELOAD.name(), context.getErrorHandler());
    return context.getRouterBuilder().createRouter();
}
Also used : SignerForIdentifier(tech.pegasys.web3signer.core.service.http.handlers.signing.SignerForIdentifier) BlockingHandlerDecorator(io.vertx.ext.web.impl.BlockingHandlerDecorator) SecpArtifactSignature(tech.pegasys.web3signer.signing.SecpArtifactSignature) RouterBuilder(io.vertx.ext.web.openapi.RouterBuilder) ArtifactSignerProvider(tech.pegasys.web3signer.signing.ArtifactSignerProvider) DefaultArtifactSignerProvider(tech.pegasys.web3signer.signing.config.DefaultArtifactSignerProvider) Eth1SignForIdentifierHandler(tech.pegasys.web3signer.core.service.http.handlers.signing.Eth1SignForIdentifierHandler) HttpApiMetrics(tech.pegasys.web3signer.core.service.http.metrics.HttpApiMetrics) LogErrorHandler(tech.pegasys.web3signer.core.service.http.handlers.LogErrorHandler)

Example 2 with HttpApiMetrics

use of tech.pegasys.web3signer.core.service.http.metrics.HttpApiMetrics in project web3signer by ConsenSys.

the class Eth2Runner method registerEth2Routes.

private void registerEth2Routes(final RouterBuilder routerBuilder, final ArtifactSignerProvider blsSignerProvider, final LogErrorHandler errorHandler, final MetricsSystem metricsSystem, final Optional<SlashingProtectionContext> slashingProtectionContext) {
    final ObjectMapper objectMapper = SigningObjectMapperFactory.createObjectMapper();
    // security handler for keymanager endpoints
    routerBuilder.securityHandler("bearerAuth", context -> {
        // TODO Auth token security logic
        final boolean authorized = true;
        if (authorized) {
            context.next();
        } else {
            context.response().setStatusCode(401).end("{ message: \"permission denied\" }");
        }
    });
    addPublicKeysListHandler(routerBuilder, blsSignerProvider, ETH2_LIST.name(), errorHandler);
    final SignerForIdentifier<BlsArtifactSignature> blsSigner = new SignerForIdentifier<>(blsSignerProvider, this::formatBlsSignature, BLS);
    routerBuilder.operation(ETH2_SIGN.name()).handler(new BlockingHandlerDecorator(new Eth2SignForIdentifierHandler(blsSigner, new HttpApiMetrics(metricsSystem, BLS), new SlashingProtectionMetrics(metricsSystem), slashingProtectionContext.map(SlashingProtectionContext::getSlashingProtection), objectMapper, eth2Spec), false)).failureHandler(errorHandler);
    addReloadHandler(routerBuilder, blsSignerProvider, RELOAD.name(), errorHandler);
    if (isKeyManagerApiEnabled) {
        routerBuilder.operation(KEYMANAGER_LIST.name()).handler(new BlockingHandlerDecorator(new ListKeystoresHandler(blsSignerProvider, objectMapper), false)).failureHandler(errorHandler);
        final ValidatorManager validatorManager = createValidatorManager(blsSignerProvider, objectMapper);
        routerBuilder.operation(KEYMANAGER_IMPORT.name()).handler(new BlockingHandlerDecorator(new ImportKeystoresHandler(objectMapper, config.getKeyConfigPath(), slashingProtectionContext.map(SlashingProtectionContext::getSlashingProtection), blsSignerProvider, validatorManager), false)).failureHandler(errorHandler);
        routerBuilder.operation(KEYMANAGER_DELETE.name()).handler(new BlockingHandlerDecorator(new DeleteKeystoresHandler(objectMapper, slashingProtectionContext.map(SlashingProtectionContext::getSlashingProtection), blsSignerProvider, validatorManager), false)).failureHandler(errorHandler);
    }
}
Also used : FileValidatorManager(tech.pegasys.web3signer.signing.FileValidatorManager) DbValidatorManager(tech.pegasys.web3signer.slashingprotection.DbValidatorManager) ValidatorManager(tech.pegasys.web3signer.signing.ValidatorManager) ListKeystoresHandler(tech.pegasys.web3signer.core.service.http.handlers.keymanager.list.ListKeystoresHandler) DeleteKeystoresHandler(tech.pegasys.web3signer.core.service.http.handlers.keymanager.delete.DeleteKeystoresHandler) SlashingProtectionMetrics(tech.pegasys.web3signer.core.metrics.SlashingProtectionMetrics) SignerForIdentifier(tech.pegasys.web3signer.core.service.http.handlers.signing.SignerForIdentifier) BlockingHandlerDecorator(io.vertx.ext.web.impl.BlockingHandlerDecorator) BlsArtifactSignature(tech.pegasys.web3signer.signing.BlsArtifactSignature) SlashingProtectionContext(tech.pegasys.web3signer.slashingprotection.SlashingProtectionContext) ImportKeystoresHandler(tech.pegasys.web3signer.core.service.http.handlers.keymanager.imports.ImportKeystoresHandler) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Eth2SignForIdentifierHandler(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SignForIdentifierHandler) HttpApiMetrics(tech.pegasys.web3signer.core.service.http.metrics.HttpApiMetrics)

Example 3 with HttpApiMetrics

use of tech.pegasys.web3signer.core.service.http.metrics.HttpApiMetrics in project web3signer by ConsenSys.

the class Eth2Runner method registerEth2Routes.

private void registerEth2Routes(final RouterBuilder routerBuilder, final ArtifactSignerProvider blsSignerProvider, final LogErrorHandler errorHandler, final MetricsSystem metricsSystem, final Optional<SlashingProtection> slashingProtection) {
    final ObjectMapper objectMapper = SigningObjectMapperFactory.createObjectMapper();
    // security handler for keymanager endpoints
    routerBuilder.securityHandler("bearerAuth", context -> {
        // TODO Auth token security logic
        final boolean authorized = true;
        if (authorized) {
            context.next();
        } else {
            context.response().setStatusCode(401).end("{ message: \"permission denied\" }");
        }
    });
    addPublicKeysListHandler(routerBuilder, blsSignerProvider, ETH2_LIST.name(), errorHandler);
    final SignerForIdentifier<BlsArtifactSignature> blsSigner = new SignerForIdentifier<>(blsSignerProvider, this::formatBlsSignature, BLS);
    routerBuilder.operation(ETH2_SIGN.name()).handler(new BlockingHandlerDecorator(new Eth2SignForIdentifierHandler(blsSigner, new HttpApiMetrics(metricsSystem, BLS), new SlashingProtectionMetrics(metricsSystem), slashingProtection, objectMapper, eth2Spec), false)).failureHandler(errorHandler);
    addReloadHandler(routerBuilder, blsSignerProvider, RELOAD.name(), errorHandler);
    if (isKeyManagerApiEnabled) {
        routerBuilder.operation(KEYMANAGER_LIST.name()).handler(new BlockingHandlerDecorator(new ListKeystoresHandler(blsSignerProvider, objectMapper), false)).failureHandler(errorHandler);
        routerBuilder.operation(KEYMANAGER_IMPORT.name()).handler(new BlockingHandlerDecorator(new ImportKeystoresHandler(objectMapper, config.getKeyConfigPath(), slashingProtection, blsSignerProvider), false)).failureHandler(errorHandler);
        routerBuilder.operation(KEYMANAGER_DELETE.name()).handler(new BlockingHandlerDecorator(new DeleteKeystoresHandler(objectMapper, new KeystoreFileManager(config.getKeyConfigPath()), slashingProtection, blsSignerProvider), false)).failureHandler(errorHandler);
    }
}
Also used : KeystoreFileManager(tech.pegasys.web3signer.core.service.http.handlers.keymanager.delete.KeystoreFileManager) ListKeystoresHandler(tech.pegasys.web3signer.core.service.http.handlers.keymanager.list.ListKeystoresHandler) DeleteKeystoresHandler(tech.pegasys.web3signer.core.service.http.handlers.keymanager.delete.DeleteKeystoresHandler) SlashingProtectionMetrics(tech.pegasys.web3signer.core.metrics.SlashingProtectionMetrics) SignerForIdentifier(tech.pegasys.web3signer.core.service.http.handlers.signing.SignerForIdentifier) BlockingHandlerDecorator(io.vertx.ext.web.impl.BlockingHandlerDecorator) BlsArtifactSignature(tech.pegasys.web3signer.core.signing.BlsArtifactSignature) ImportKeystoresHandler(tech.pegasys.web3signer.core.service.http.handlers.keymanager.imports.ImportKeystoresHandler) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Eth2SignForIdentifierHandler(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SignForIdentifierHandler) HttpApiMetrics(tech.pegasys.web3signer.core.service.http.metrics.HttpApiMetrics)

Aggregations

BlockingHandlerDecorator (io.vertx.ext.web.impl.BlockingHandlerDecorator)3 SignerForIdentifier (tech.pegasys.web3signer.core.service.http.handlers.signing.SignerForIdentifier)3 HttpApiMetrics (tech.pegasys.web3signer.core.service.http.metrics.HttpApiMetrics)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 SlashingProtectionMetrics (tech.pegasys.web3signer.core.metrics.SlashingProtectionMetrics)2 DeleteKeystoresHandler (tech.pegasys.web3signer.core.service.http.handlers.keymanager.delete.DeleteKeystoresHandler)2 ImportKeystoresHandler (tech.pegasys.web3signer.core.service.http.handlers.keymanager.imports.ImportKeystoresHandler)2 ListKeystoresHandler (tech.pegasys.web3signer.core.service.http.handlers.keymanager.list.ListKeystoresHandler)2 Eth2SignForIdentifierHandler (tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SignForIdentifierHandler)2 RouterBuilder (io.vertx.ext.web.openapi.RouterBuilder)1 LogErrorHandler (tech.pegasys.web3signer.core.service.http.handlers.LogErrorHandler)1 KeystoreFileManager (tech.pegasys.web3signer.core.service.http.handlers.keymanager.delete.KeystoreFileManager)1 Eth1SignForIdentifierHandler (tech.pegasys.web3signer.core.service.http.handlers.signing.Eth1SignForIdentifierHandler)1 BlsArtifactSignature (tech.pegasys.web3signer.core.signing.BlsArtifactSignature)1 ArtifactSignerProvider (tech.pegasys.web3signer.signing.ArtifactSignerProvider)1 BlsArtifactSignature (tech.pegasys.web3signer.signing.BlsArtifactSignature)1 FileValidatorManager (tech.pegasys.web3signer.signing.FileValidatorManager)1 SecpArtifactSignature (tech.pegasys.web3signer.signing.SecpArtifactSignature)1 ValidatorManager (tech.pegasys.web3signer.signing.ValidatorManager)1 DefaultArtifactSignerProvider (tech.pegasys.web3signer.signing.config.DefaultArtifactSignerProvider)1