dropwizard-auth-jwt

A simple to use dropwizard jwt auth library

Лицензия

Лицензия

Категории

Категории

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

Группа

com.github.mambabosso
Идентификатор

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

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

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

1.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

dropwizard-auth-jwt
A simple to use dropwizard jwt auth library
Ссылка на сайт

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

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

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

https://github.com/Mambabosso/dropwizard-auth-jwt

Скачать dropwizard-auth-jwt

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

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

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
com.auth0 : java-jwt jar 3.10.2

provided (3)

Идентификатор библиотеки Тип Версия
io.dropwizard : dropwizard-auth jar 2.0.8
com.fasterxml.jackson.core : jackson-databind jar 2.10.3
org.projectlombok : lombok jar 1.18.12

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

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

dropwizard-auth-jwt

Maven

<dependency>
    <groupId>com.github.mambabosso</groupId>
    <artifactId>dropwizard-auth-jwt</artifactId>
    <version>1.1</version>
</dependency>

Getting started

Example

Example Code - Link

Configuration

@Valid
@NotNull
private JwtConfiguration jwtConfiguration;

@JsonProperty("jwt")
public JwtConfiguration getJwtConfiguration() {
    return jwtConfiguration;
}

@JsonProperty("jwt")
public void setJwtConfiguration(JwtConfiguration jwtConfiguration) {
    this.jwtConfiguration = jwtConfiguration;
}

Application

In this example the class 'User' is our principal

authenticator = DefaultJwtAuthenticator.create(configuration.getJwtConfiguration(), User.class);

OAuthCredentialAuthFilter.Builder<User> oauthBuilder = new OAuthCredentialAuthFilter.Builder<>();
oauthBuilder.setAuthenticator(authenticator);
oauthBuilder.setPrefix("Bearer");

environment.jersey().register(new AuthDynamicFeature(oauthBuilder.buildAuthFilter()));

Tokens

Encode

Optional<String> token = authenticator.getJwtHandler().encode(userObject);
// do something with the token

Decode

Optional<User> user = authenticator.getJwtHandler().decode(token);
// do something with the user

Credits

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

Версия
1.2
1.1