dropwizard-api-key-bundle

Dropwizard bundle that allows your application to support API keys.

Лицензия

Лицензия

Категории

Категории

DropWizard Контейнер Микросервисы KeY Данные Data Formats Formal Verification
Группа

Группа

io.dropwizard-bundles
Идентификатор

Идентификатор

dropwizard-api-key-bundle
Последняя версия

Последняя версия

0.8.5
Дата

Дата

Тип

Тип

jar
Описание

Описание

dropwizard-api-key-bundle
Dropwizard bundle that allows your application to support API keys.
Система контроля версий

Система контроля версий

http://github.com/dropwizard-bundles/dropwizard-api-key-bundle

Скачать dropwizard-api-key-bundle

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.dropwizard-bundles/dropwizard-api-key-bundle/ -->
<dependency>
    <groupId>io.dropwizard-bundles</groupId>
    <artifactId>dropwizard-api-key-bundle</artifactId>
    <version>0.8.5</version>
</dependency>
// https://jarcasting.com/artifacts/io.dropwizard-bundles/dropwizard-api-key-bundle/
implementation 'io.dropwizard-bundles:dropwizard-api-key-bundle:0.8.5'
// https://jarcasting.com/artifacts/io.dropwizard-bundles/dropwizard-api-key-bundle/
implementation ("io.dropwizard-bundles:dropwizard-api-key-bundle:0.8.5")
'io.dropwizard-bundles:dropwizard-api-key-bundle:jar:0.8.5'
<dependency org="io.dropwizard-bundles" name="dropwizard-api-key-bundle" rev="0.8.5">
  <artifact name="dropwizard-api-key-bundle" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.dropwizard-bundles', module='dropwizard-api-key-bundle', version='0.8.5')
)
libraryDependencies += "io.dropwizard-bundles" % "dropwizard-api-key-bundle" % "0.8.5"
[io.dropwizard-bundles/dropwizard-api-key-bundle "0.8.5"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
io.dropwizard : dropwizard-core jar 0.8.5
io.dropwizard : dropwizard-auth jar 0.8.5

test (4)

Идентификатор библиотеки Тип Версия
io.dropwizard : dropwizard-testing jar 0.8.5
org.glassfish.jersey.test-framework.providers : jersey-test-framework-provider-grizzly2 jar 2.21
junit : junit jar 4.12
org.mockito : mockito-core jar 1.10.17

Модули Проекта

Данный проект не имеет модулей.

dropwizard-api-key-bundle

A Dropwizard bundle that provides a simple way to manage API keys for callers of your service.

[Build Status] (http://travis-ci.org/dropwizard-bundles/dropwizard-api-key-bundle)

Getting Started

Just add this maven dependency to get started:

<dependency>
  <groupId>io.dropwizard-bundles</groupId>
  <artifactId>dropwizard-api-key-bundle</artifactId>
  <version>0.8.4-1</version>
</dependency>

Add the bundle to your environment:

public class MyApplication extends Application<MyConfiguration> {
  @Override
  public void initialize(Bootstrap<MyConfiguration> bootstrap) {
    bootstrap.addBundle(new ApiKeyBundle<>());
  }

  @Override
  public void run(MyConfiguration cfg, Environment env) throws Exception {
    // ...
  }
}

You will also need to make your MyConfiguration class implement ApiKeyBundleConfiguration in order to provide the bundle with the necessary information it needs to know your API keys.

public class MyConfiguration implements ApiKeyBundleConfiguration {
  @Valid
  @NotNull
  @JsonProperty("authentication")
  private final ApiKeyConfiguration apiKeyConfiguration = null;

  /**
   * Return the API key configuration.
   */
  @Override
  public ApiKeyConfiguration getApiKeyConfiguration() {
    return apiKeyConfiguration;
  }

Now you can use API key based authentication in your application by declaring a method on a resource that has an @Auth annotated String parameter. See the Dropwizard Authentication documentation for more details. The passed in parameter value will be the name of the application that made the request if the authentication process was successful.

As far as configuration goes you can define your API keys in your application's config file. Assuming, like in the above example, you called your API key configuration element authentication then you can use a config file like this:

authentication:
  basic-http:
    cache-spec: maximumSize=1000, expireAfterAccess=10m
    realm: MyApplication
    keys:
      application-1: api-key-1
      application-2: api-key-2
io.dropwizard-bundles

Dropwizard Bundles

Reusable Dropwizard Bundles

Версии библиотеки

Версия
0.8.5
0.8.4-1
0.8.4