| |
---|
| | import gitbucket.core.model.Profile.profile.blockingApi._ |
---|
| | import gitbucket.core.model.{AccessToken, Account} |
---|
| | import gitbucket.core.util.StringUtil |
---|
| | |
---|
| | import scala.util.Random |
---|
| | import java.security.SecureRandom |
---|
| | |
---|
| | trait AccessTokenService { |
---|
| | |
---|
| | def makeAccessTokenString: String = { |
---|
| | val bytes = new Array[Byte](20) |
---|
| | Random.nextBytes(bytes) |
---|
| | AccessTokenService.secureRandom.nextBytes(bytes) |
---|
| | bytes.map("%02x".format(_)).mkString |
---|
| | } |
---|
| | |
---|
| | def tokenToHash(token: String): String = StringUtil.sha1(token) |
---|
| |
---|
| | AccessTokens filter (t => t.userName === userName.bind && t.accessTokenId === accessTokenId) delete |
---|
| | |
---|
| | } |
---|
| | |
---|
| | object AccessTokenService extends AccessTokenService |
---|
| | object AccessTokenService extends AccessTokenService { |
---|
| | private val secureRandom = new SecureRandom() |
---|
| | } |
---|
| | |
---|
| | |