diff --git a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/connection.scala b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/connection.scala index 517bedc5..fa63ea0e 100644 --- a/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/connection.scala +++ b/modules/effects/src/main/scala/dev/profunktor/redis4cats/algebra/connection.scala @@ -16,9 +16,14 @@ package dev.profunktor.redis4cats.algebra -trait ConnectionCommands[F[_]] extends Ping[F] +trait ConnectionCommands[F[_]] extends Ping[F] with Auth[F] trait Ping[F[_]] { def ping: F[String] def select(index: Int): F[Unit] } + +trait Auth[F[_]] { + def auth(password: CharSequence): F[Boolean] + def auth(username: String, password: CharSequence): F[Boolean] +} diff --git a/modules/effects/src/main/scala/dev/profunktor/redis4cats/redis.scala b/modules/effects/src/main/scala/dev/profunktor/redis4cats/redis.scala index fc1415c9..0778a920 100644 --- a/modules/effects/src/main/scala/dev/profunktor/redis4cats/redis.scala +++ b/modules/effects/src/main/scala/dev/profunktor/redis4cats/redis.scala @@ -1248,6 +1248,18 @@ private[redis4cats] class BaseRedis[F[_]: Concurrent: ContextShift: Log, K, V]( override def select(index: Int): F[Unit] = conn.async.flatMap(c => blocker.delay(c.select(index))).void + override def auth(password: CharSequence): F[Boolean] = + async + .flatMap(c => F.delay(c.auth(password))) + .futureLift + .map(_ == "OK") + + override def auth(username: String, password: CharSequence): F[Boolean] = + async + .flatMap(c => F.delay(c.auth(username, password))) + .futureLift + .map(_ == "OK") + /******************************* Server API **********************************/ override val flushAll: F[Unit] = async.flatMap(c => F.delay(c.flushall())).futureLift.void