Skip to content
Snippets Groups Projects
Commit 166dbd41 authored by Tomas Madeja's avatar Tomas Madeja
Browse files

feat: add Argon2 service

parent ecd49d02
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,13 @@
<version>2.4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.4.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
......
......@@ -88,6 +88,12 @@
<artifactId>dozer-core</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
</dependencies>
......
......@@ -7,6 +7,7 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;
import org.springframework.transaction.annotation.EnableTransactionManagement;
......@@ -24,4 +25,17 @@ public class ApplicationConfig {
return mapperBuilder.build();
}
@Bean
public Argon2PasswordEncoder argon2Encoder() {
/*
Recommended parameters:
- hash and salt - each at least 16
- parallellism - twice the core count
- memory - at least 4 GB
- iterations - adjustable
Note: adjust memory and iterations to hit response time: 0.5-1 sec
*/
int cores = Runtime.getRuntime().availableProcessors();
return new Argon2PasswordEncoder(32, 32, cores*2, 3906250, 1);
}
}
package cz.muni.fi.pa165.icehockeymanager.services;
public interface Argon2Service {
}
package cz.muni.fi.pa165.icehockeymanager.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
@Service
@Transactional
public class Argon2ServiceImpl {
private final Argon2PasswordEncoder encoder;
@Autowired
public Argon2ServiceImpl(Argon2PasswordEncoder encoder) {
this.encoder = encoder;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment