Spring Boot autoconfiguration for pwnedpasswords.com

Spring Boot autoconfiguration for easy checking passwords against the pwdpassword service of Troy Hunt

Лицензия

Лицензия

Категории

Категории

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

Группа

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

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

pwnedpasswords4j-spring-boot-starter
Последняя версия

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

1.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Spring Boot autoconfiguration for pwnedpasswords.com
Spring Boot autoconfiguration for easy checking passwords against the pwdpassword service of Troy Hunt

Скачать pwnedpasswords4j-spring-boot-starter

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

<!-- https://jarcasting.com/artifacts/com.github.nbaars/pwnedpasswords4j-spring-boot-starter/ -->
<dependency>
    <groupId>com.github.nbaars</groupId>
    <artifactId>pwnedpasswords4j-spring-boot-starter</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.nbaars/pwnedpasswords4j-spring-boot-starter/
implementation 'com.github.nbaars:pwnedpasswords4j-spring-boot-starter:1.1.0'
// https://jarcasting.com/artifacts/com.github.nbaars/pwnedpasswords4j-spring-boot-starter/
implementation ("com.github.nbaars:pwnedpasswords4j-spring-boot-starter:1.1.0")
'com.github.nbaars:pwnedpasswords4j-spring-boot-starter:jar:1.1.0'
<dependency org="com.github.nbaars" name="pwnedpasswords4j-spring-boot-starter" rev="1.1.0">
  <artifact name="pwnedpasswords4j-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.nbaars', module='pwnedpasswords4j-spring-boot-starter', version='1.1.0')
)
libraryDependencies += "com.github.nbaars" % "pwnedpasswords4j-spring-boot-starter" % "1.1.0"
[com.github.nbaars/pwnedpasswords4j-spring-boot-starter "1.1.0"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
com.github.nbaars : pwnedpasswords4j-client jar 1.1.0
org.springframework.boot : spring-boot-autoconfigure jar
org.springframework.boot : spring-boot-configuration-processor Необязательный jar

test (5)

Идентификатор библиотеки Тип Версия
junit : junit jar
org.mockito : mockito-core jar
org.springframework.boot : spring-boot-starter-test jar
org.slf4j : slf4j-api jar
org.slf4j : jcl-over-slf4j jar

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

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

Java client for pwnedpasswords.com

Build Status Maintainability Quality Gate Coverage

Introduction

A Java client for checking a password against pwnedpasswords.com using the Searching by range API For more details see: https://haveibeenpwned.com/API/v2#SearchingPwnedPasswordsByRange

News: Artifacts are available through Maven Central

Pure Java client

The artifact client can be used in a standalone Java program and does not rely on Spring Boot To use the checker you need to add the following library to the pom.xml:

<dependency>
  <groupId>com.github.nbaars</groupId>
  <artifactId>pwnedpasswords4j-client</artifactId>
  <version>1.1.0</version>
</dependency>

In the code you can check a password as follows:

PwnedPasswordChecker checker = PwnedPasswordChecker.standalone("My user agent")
boolean result = checker.check("password");

//OR for non blocking:

CompletableFuture<Boolean> result = checker.asyncCheck("password");

The user-agent is necessary to specify as described in the API description at haveibeenpwned.com.

Spring Boot autoconfigure

For Spring Boot there is an autoconfigure module, to use this use the following dependency inside your project:

<dependency>
  <groupId>com.github.nbaars</groupId>
  <artifactId>pwnedpasswords4j-spring-boot-starter</artifactId>
  <version>1.0.1</version>
</dependency>

In the application.properties you should add:

pwnedpasswords4j.user_agent=Testing   # Required as described in the documentation of haveibeenpwned.com API
pwnedpasswords4j.url=https://api.pwnedpasswords.com/range/ # Optional

Wire up the checker as follows:

 @Autowired
 private PwnedPasswordChecker checker;
 
 ...
 
 public void signup() {
    boolean result = checker.check("password");
    
    //or for non-blocking use:
    
    CompletableFuture<Boolean> result = checker.asyncCheck("password");
 }
 
    

As an example see the demo project:

@RestController
public class SignupController {

    @Autowired
    private PwnedPasswordChecker checker;

    @PostMapping
    public ResponseEntity<?> login(@RequestBody Login login) {
        if (checker.check("password")) {
            return ResponseEntity.badRequest().body("Consider changing your password");
        }
        return ResponseEntity.ok().build();
    }
}

Releasing

This is a manual process for now, make sure the GPG keys are in place

mvn clean deploy -Prelease

Go to https://oss.sonatype.org/#stagingRepositories and search the uploaded bundle, click Close wait for all the rules to finish and click Release.

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

Версия
1.1.0
1.0.0.0