mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 05:25:50 +01:00
Add bearer authentification (#3725)
Co-authored-by: mnival <extern.nival_michael@allianz.com>
This commit is contained in:
@@ -25,8 +25,8 @@ class ApiAuthenticationFilter extends Filter with AccessTokenService with Accoun
|
|||||||
val response = res.asInstanceOf[HttpServletResponse]
|
val response = res.asInstanceOf[HttpServletResponse]
|
||||||
Option(request.getHeader("Authorization"))
|
Option(request.getHeader("Authorization"))
|
||||||
.map {
|
.map {
|
||||||
case auth if auth.toLowerCase().startsWith("token ") =>
|
case auth if auth.toLowerCase().startsWith("token ") || auth.toLowerCase().startsWith("bearer ") =>
|
||||||
AccessTokenService.getAccountByAccessToken(auth.substring(6).trim).toRight(())
|
AccessTokenService.getAccountByAccessToken(auth.substring(auth.indexOf(" ") + 1).trim).toRight(())
|
||||||
case auth if auth.startsWith("Basic ") => doBasicAuth(auth, loadSystemSettings(), request).toRight(())
|
case auth if auth.startsWith("Basic ") => doBasicAuth(auth, loadSystemSettings(), request).toRight(())
|
||||||
case _ => Left(())
|
case _ => Left(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user