feat(security): #286 first try on csrf
Some checks failed
Build Docker Image / Build-Docker-Image (push) Failing after 38s
Some checks failed
Build Docker Image / Build-Docker-Image (push) Failing after 38s
This commit is contained in:
@@ -71,7 +71,7 @@ type Auth interface {
|
||||
SendForgotPasswordMail(email string) error
|
||||
ForgotPassword(token string, newPass string) error
|
||||
|
||||
IsCsrfTokenValid(tokenStr string, userId uuid.UUID) bool
|
||||
IsCsrfTokenValid(tokenStr string, sessionId string) bool
|
||||
GetCsrfToken(session *Session) (string, error)
|
||||
}
|
||||
|
||||
@@ -394,14 +394,14 @@ func (service AuthImpl) ForgotPassword(tokenStr string, newPass string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (service AuthImpl) IsCsrfTokenValid(tokenStr string, userId uuid.UUID) bool {
|
||||
func (service AuthImpl) IsCsrfTokenValid(tokenStr string, sessionId string) bool {
|
||||
token, err := service.db.GetToken(tokenStr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if token.Type != db.TokenTypeCsrf ||
|
||||
token.UserId != userId ||
|
||||
token.SessionId != sessionId ||
|
||||
token.ExpiresAt.Before(service.clock.Now()) {
|
||||
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user