zoukankan      html  css  js  c++  java
  • cubestore 添加auth 认证

    实际上官方支持auth 的认证的,只是模式为None,我们可以自定义自己的一个auth,以下主要说明下关于mysql 协议的,因为特殊性
    http 走的是websocket(后期添加)

    参考修改的代码

    • auth
     
    #[async_trait]
    impl SqlAuthService for SqlAuthDefaultImpl {
        async fn authenticate(&self, _user: Option<String>) -> Result<Option<String>, CubeError> {
          let m =  match _user {
                None => {
                    println!("{}", "user is null");
                    Err(CubeError {
                        message: "error".to_string(),
                        cause: CubeErrorCauseType::User,
                    })
                }
                Some(user) => {
                    println!("auth user{}", user);
                    Ok(None)
                }
            };
            m
        }
    }
    • 协议处理
     tokio::spawn(async move {
                    if let Err(e) = AsyncMysqlIntermediary::run_on(
                        Backend {
                            sql_service,
                            auth,
                           // 使用自定义环境变量
                            user: env::var("CUBESTORE_USERNAME").ok(),
                        },
                        socket,
                    )
                    .await
                    {
                        error!("Error during processing MySQL connection: {}", e);
                    }
                });

    运行

    export CUBESTORE_LOG_LEVEL=debug
    export CUBESTORE_SERVER_NAME=localhost:9999
    export CUBESTORE_META_PORT=9999
    export CUBESTORE_S3_BUCKET=test
    export CUBESTORE_S3_ENDPOINT=http://localhost:9000
    export CUBESTORE_S3_REGION=us-east-1
    export CUBESTORE_S3_PATH_STYLE=1
    export CUBESTORE_USERNAME=dalong
    export CUBESTORE_REMOTE_DIR=./cube/data
    export CUBESTORE_AWS_ACCESS_KEY_ID=dalongrong
    export CUBESTORE_AWS_SECRET_ACCESS_KEY=dalongrong
     ./target/debug/cubestored 

    使用

    可以使用以下命令测试

    mysql -udalong -h127.0.0.1 

    说明

    因为http 以及websocket 的特殊性,后期调整添加

  • 相关阅读:
    php的冒泡算法
    mysql 处理重复数据
    Ehcache配置详解及CacheManager使用
    JFinal常见问题和知识点笔记
    JFinal连接数据库配置说明
    innerHTML和innerText区分
    方法$.data()和$.('#test').on()的使用
    input text的所有事件
    jQuery操作Select
    在js或css后加?v= 版本号不让浏览器缓存
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/14737227.html
Copyright © 2011-2022 走看看