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