dropwizard-simpleauth

A Dropwizard library for simple @Auth

Лицензия

Лицензия

Категории

Категории

DropWizard Контейнер Микросервисы
Группа

Группа

org.whispersystems
Идентификатор

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

dropwizard-simpleauth
Последняя версия

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

0.4.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

dropwizard-simpleauth
A Dropwizard library for simple @Auth
Ссылка на сайт

Ссылка на сайт

https://github.com/WhisperSystems/dropwizard-simpleauth
Система контроля версий

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

https://github.com/WhisperSystems/dropwizard-simpleauth

Скачать dropwizard-simpleauth

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

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

Зависимости

compile (1)

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

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.mockito : mockito-all jar 1.10.19

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

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

dropwizard-simpleauth

A Dropwizard library that lets you use simple @Auth annotations for authenticating multiple types, without having to deal with @RolesAllowed style authorizations.

Install from maven central:

<dependency>
  <groupId>org.whispersystems</groupId>
  <artifactId>dropwizard-simpleauth</artifactId>
  <version>${latest_version}</version>
</dependency>

The details

This library allows writing an authenticated Dropwizard resource to look like this:

@Path("/api/v1/mail")
public class MailResource {

  @Timed
  @POST
  @Path("/{destination}/")
  @Consumes(MediaType.APPLICATION_JSON_TYPE)
  public void sendMessage(@Auth User sender,
                          @PathParam("destination") String destination,
                          @Valid Message message)
  {
    ...
  }
  
  @Timed
  @DELETE
  @Path("/{messageId}/")
  public void sendMessage(@Auth Admin admin,
                          @PathParam("messageId") long messageId)
  {
    ...
  }
  
  
}

No "authorization" tags like @AllowAll, @DenyAll, @RolesAllowed are used. Instead, the @Auth tag allows you to authenticate multiple different "principal" types (in this example both User and Admin), neither of which have to extend Principal.

Registering authenticators

To support authenticating multiple types, register multiple AuthFilters:

@Override
public void run(ExampleConfiguration configuration,
                Environment environment) 
{
    environment.jersey().register(new AuthDynamicFeature(
            new BasicCredentialAuthFilter.Builder<User>()
                .setAuthenticator(new UserAuthenticator())
                .setPrincipal(User.class)
                .buildAuthFilter(),
            new BasicCredentialAuthFilter.Builder<Admin>()
                .setAuthenticator(new AdminAuthenticator())
                .setPrincipal(Admin.class)
                .buildAuthFilter()));

    environment.jersey().register(new AuthValueFactoryProvider.Binder());
}

That's it!

org.whispersystems

Open Whisper Systems

The Signal repositories have moved to github.com/signalapp

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

Версия
0.4.0
0.3.0
0.2.0
0.1.1
0.1.0