-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
306 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/vauthenticator/server/config/PasswordGeneratorConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ain/kotlin/com/vauthenticator/server/oauth2/clientapp/domain/ClientApplicationUseCases.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
src/main/kotlin/com/vauthenticator/server/password/PasswordEncoder.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...ator/server/password/adapter/spring/Argon2PasswordEncoderVAuthenticatorPasswordEncoder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.vauthenticator.server.password.adapter.spring | ||
|
||
import com.vauthenticator.server.password.domain.VAuthenticatorPasswordEncoder | ||
import org.springframework.security.crypto.password.PasswordEncoder | ||
|
||
class Argon2PasswordEncoderVAuthenticatorPasswordEncoder(private val passwordEncoder: PasswordEncoder) : | ||
VAuthenticatorPasswordEncoder { | ||
|
||
override fun encode(password: String): String = passwordEncoder.encode(password) | ||
override fun matches(password: String, encodedPassword: String): Boolean = | ||
passwordEncoder.matches(password, encodedPassword) | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
.../com/vauthenticator/server/password/adapter/spring/BcryptVAuthenticatorPasswordEncoder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.vauthenticator.server.password.adapter.spring | ||
|
||
import com.vauthenticator.server.password.domain.VAuthenticatorPasswordEncoder | ||
import org.springframework.security.crypto.password.PasswordEncoder | ||
|
||
class BcryptVAuthenticatorPasswordEncoder(private val passwordEncoder: PasswordEncoder) : | ||
VAuthenticatorPasswordEncoder { | ||
|
||
override fun encode(password: String): String = passwordEncoder.encode(password) | ||
override fun matches(password: String, encodedPassword: String): Boolean = | ||
passwordEncoder.matches(password, encodedPassword) | ||
|
||
} |
6 changes: 4 additions & 2 deletions
6
.../changepassword/ChangePasswordEndPoint.kt → ...er/password/api/ChangePasswordEndPoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/com/vauthenticator/server/password/api/PasswordGeneratorEndPoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.vauthenticator.server.password.api | ||
|
||
import com.vauthenticator.server.password.domain.PasswordGenerator | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
class PasswordGeneratorEndPoint(private val passwordGenerator: PasswordGenerator) { | ||
|
||
@PostMapping("/api/password") | ||
fun generate() = ResponseEntity.ok(GeneratedPasswordResponse(passwordGenerator.generate())) | ||
} | ||
|
||
data class GeneratedPasswordResponse(val pwd: String) |
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/com/vauthenticator/server/password/api/RestePasswordEndPoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.vauthenticator.server.password.api | ||
|
||
import com.vauthenticator.server.oauth2.clientapp.domain.Scope | ||
import com.vauthenticator.server.oauth2.clientapp.domain.Scopes | ||
import com.vauthenticator.server.password.domain.resetpassword.ResetAccountPassword | ||
import com.vauthenticator.server.password.domain.resetpassword.SendResetPasswordMailChallenge | ||
import com.vauthenticator.server.role.domain.PermissionValidator | ||
import com.vauthenticator.server.ticket.domain.TicketId | ||
import jakarta.servlet.http.HttpSession | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.http.ResponseEntity.noContent | ||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@RestController | ||
@SessionAttributes("clientId") | ||
class ResetPasswordEndPoint( | ||
private val permissionValidator: PermissionValidator, | ||
private val sendResetPasswordMailChallenge: SendResetPasswordMailChallenge, | ||
private val resetAccountPassword: ResetAccountPassword | ||
) { | ||
|
||
@PutMapping("/api/reset-password-challenge") | ||
fun sendVerifyMail( | ||
@RequestBody request: Map<String, String>, | ||
session: HttpSession, | ||
principal: JwtAuthenticationToken? | ||
): ResponseEntity<Unit> { | ||
permissionValidator.validate(principal, session, Scopes.from(Scope.RESET_PASSWORD)) | ||
sendResetPasswordMailChallenge.sendResetPasswordMailFor(request["email"]!!) | ||
return noContent().build() | ||
} | ||
|
||
@PutMapping("/api/reset-password/{ticket}") | ||
fun resetPassword(@PathVariable ticket: String, @RequestBody request: ResetPasswordRequest): ResponseEntity<Unit> { | ||
resetAccountPassword.resetPasswordFromMailChallenge(TicketId(ticket), request) | ||
return noContent().build() | ||
} | ||
|
||
} | ||
|
||
data class ResetPasswordRequest(val newPassword: String) |
2 changes: 1 addition & 1 deletion
2
...authenticator/server/password/Password.kt → ...icator/server/password/domain/Password.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.vauthenticator.server.password | ||
package com.vauthenticator.server.password.domain | ||
|
||
@JvmInline | ||
value class Password(val content: String) |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/com/vauthenticator/server/password/domain/PasswordEncoder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.vauthenticator.server.password.domain | ||
|
||
interface VAuthenticatorPasswordEncoder { | ||
fun encode(password: String): String | ||
|
||
fun matches(password: String, encodedPassword: String): Boolean | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/com/vauthenticator/server/password/domain/PasswordHistoryRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.vauthenticator.server.password.domain | ||
|
||
interface PasswordHistoryRepository { | ||
|
||
fun store(userName: String, password: Password) | ||
fun load(userName: String): List<Password> | ||
|
||
} | ||
|
Oops, something went wrong.