-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using only user.name in internal authentication
### What's done: It's part of #2336
- Loading branch information
Showing
15 changed files
with
111 additions
and
78 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...tlin/com/saveourtool/save/authservice/repository/AuthenticationOriginalLoginRepository.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,35 @@ | ||
package com.saveourtool.save.authservice.repository | ||
|
||
import com.saveourtool.save.authservice.utils.toUserEntity | ||
import com.saveourtool.save.entities.User | ||
import com.saveourtool.save.utils.orNotFound | ||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate | ||
import org.springframework.stereotype.Component | ||
|
||
/** | ||
* Repository for [com.saveourtool.save.entities.User] using _original_login_ | ||
*/ | ||
@Component | ||
class AuthenticationOriginalLoginRepository( | ||
private val namedParameterJdbcTemplate: NamedParameterJdbcTemplate, | ||
) { | ||
/** | ||
* @param name name of user | ||
* @param source source of user | ||
* @return user or null if no results have been found | ||
*/ | ||
fun findByNameAndSource(name: String, source: String): User? = namedParameterJdbcTemplate.queryForList( | ||
"SELECT * FROM save_cloud.user WHERE id = (select user_id from save_cloud.original_login where name = :name AND source = :source)", | ||
mapOf("name" to name, "source" to source) | ||
) | ||
.firstOrNull() | ||
?.toUserEntity() | ||
|
||
/** | ||
* @param name name of user | ||
* @param source source of user | ||
* @return user or exception if no results have been found | ||
*/ | ||
fun getByNameAndSource(name: String, source: String): User = findByNameAndSource(name, source) | ||
.orNotFound { "There is no user with name $name and source $source" } | ||
} |
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
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
Oops, something went wrong.