MicroProfile JWT Login

Library to enable JWT token generation for Microprofile Projects

Лицензия

Лицензия

Группа

Группа

io.github.gdiazs
Идентификатор

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

microprofile-jwt-login
Последняя версия

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

0.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

MicroProfile JWT Login
Library to enable JWT token generation for Microprofile Projects
Ссылка на сайт

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

https://github.com/gdiazs/microprofile-jwt-login
Система контроля версий

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

http://github.com/gdiazs/microprofile-jwt-login/tree/master

Скачать microprofile-jwt-login

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

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

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
com.nimbusds : nimbus-jose-jwt jar 5.7
org.bouncycastle : bcpkix-jdk15on jar 1.53
at.favre.lib : bcrypt jar 0.7.0

provided (1)

Идентификатор библиотеки Тип Версия
org.eclipse.microprofile : microprofile pom 1.2

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

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

microprofile-jwt-login

This library was built for Demo purposes it's not recommended at production.

This tiny library let's you create an authentication microservice with Microprofile. You should provide your own implementation of UserService interface to tells to the login service where fetch the user data.

By default this library uses JOSE implementation to creates JWT. Has a password validation in order to validate user credentials. Uses BCrypt with salt to verify the encoded password. You can see the dependencies in pom.xml

On your Microprofile project

Maven Central

  <dependency>
    <groupId>io.github.gdiazs</groupId>
    <artifactId>microprofile-jwt-login</artifactId>
    <version>0.0.2</version>
  </dependency>

Create UserService implementation or use in memory approach for testing

Once you have imported this library in a Microprofile project built with https://start.microprofile.io/ Just configure a similar class like this. You can provide your own user service implementation to fetch your user data.

   @Dependent
   public class AuthservicesConfig {

     @Produces
     public UserService userService() {

       UserServiceBuilder.userBuilder()
                 .addUser("gdiazs", "$2y$06$HJMVVcT0mBshzc9ZCLtJXuwi0R4CPuKGbJDGVlyGYAt6KnM9UfC6C", "admin", "tester")
                 .addUser("memo", "$2y$06$HJMVVcT0mBshzc9ZCLtJXuwi0R4CPuKGbJDGVlyGYAt6KnM9UfC6C", "developer");

       return UserServiceBuilder.build();
     }


     @Produces
     public PasswordEncoder passwordEncoder() {
       return new PasswordEncoderDefault(6);
     }
   }

Configure the Microprofile config properties

Don't forget add this properties

microprofile-config.properties

microprofile.jwt.secret=yoursecrethash
microprofile.jwt.privateKey=/privateKey.pem
microprofile.jwt.algorithm=RS256 # or HS256 depends on this the library uses secret or privateKey
microprofile.jwt.aud=web
microprofile.jwt.iss=https://server.example.com
microprofile.jwt.expiration=30000
microprofile.jwt.keyID=JWT-MP

Test your auth microservice

POST http://localhost:port/context/auth
{ 
  "username": "gdiazs",
  "password": "Test1234"
}

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

Версия
0.0.2
0.0.1