dragonflydb / dragonfly

A modern replacement for Redis and Memcached
https://www.dragonflydb.io/
Other
25.47k stars 926 forks source link

no support use hello auth for resp3 #1196

Closed wacdev closed 1 year ago

wacdev commented 1 year ago

i use docker.dragonflydb.io/dragonflydb/dragonfly

use fred.rs with resp3 https://github.com/aembke/fred.rs

https://redis.io/commands/hello/

fred.rs use HELLO protover [AUTH username password] [SETNAME clientname] for auth

use dragonfly will cause error

Authentication Error: NOAUTH Authentication required

fred.rs code

    /// Authenticate via HELLO in RESP3 mode or AUTH in RESP2 mode, then set the client name.
    pub async fn switch_protocols_and_authenticate(&mut self, inner: &Arc<RedisClientInner>) -> Result<(), RedisError> {
      // reset the protocol version to the one specified by the config when we create new connections
      inner.reset_protocol_version();
      let username = inner.config.username.clone();
      let password = inner.config.password.clone();

      if inner.is_resp3() {
        _debug!(inner, "Switching to RESP3 protocol with HELLO...");
        let args = if let Some(password) = password {
          if let Some(username) = username {
            vec![username.into(), password.into()]
          } else {
            vec!["default".into(), password.into()]
          }
        } else {
          vec![]
        };

        let cmd = RedisCommand::new(RedisCommandKind::_Hello(RespVersion::RESP3), args);
        let response = self.request_response(cmd, true).await?;
        let response = protocol_utils::frame_to_results(response)?;
        inner.switch_protocol_versions(RespVersion::RESP3);
        _trace!(inner, "Recv HELLO response {:?}", response);

        Ok(())
      } else {
        self.authenticate(&inner.id, username, password, false).await
      }
adiholden commented 1 year ago

Hi @wacdev , Currently Dragonfly supports only password protected server via requierpass, it does not support ACL - https://redis.io/docs/management/security/acl/

Are you using "default" username? if so ,the auth via hello command should work

wacdev commented 1 year ago

I'm using the default user, I googled and I'm guessing maybe the latest version on docker doesn't include this commit? Can a new version be released?

feat(server): allow AUTH and SETNAME options in the HELLO command #1156 https://github.com/dragonflydb/dragonfly/pull/1156/commits/c54584538ae7567ff589aaf4268add6ab3d7fb39

adiholden commented 1 year ago

@wacdev you are totally right! a new version will be released on 15.5

adiholden commented 1 year ago

@wacdev FYI, Dragonfly v1.3.0 supports this API.