Skip to content

Commit

Permalink
example: more secure string compare for login
Browse files Browse the repository at this point in the history
  • Loading branch information
MasseGuillaume authored Mar 6, 2022
1 parent 2bbeb9b commit d5a1f21
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion example/src/main/scala/example/Authentication.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object Authentication extends App {
// App that let's the user login
// Login is successful only if the password is the reverse of the username
def login: UHttpApp = Http.collect[Request] { case Method.GET -> !! / "login" / username / password =>
if (password.reverse == username) Response.text(jwtEncode(username))
if (password.reverse.hashCode == username.hashCode) Response.text(jwtEncode(username))
else Response.fromHttpError(HttpError.Unauthorized("Invalid username of password\n"))
}

Expand Down

0 comments on commit d5a1f21

Please sign in to comment.