• Greenplum身份验证方式-密码验证


    基于密码的身份验证方式有两种:password 和 md5 ;

    Password是明文密码 md5是加密后的密码

    测试方法类似于基于IP的trust reject身份验证方式,但数据库连接参数 密码需要赋值。

    首先新建两个用户  user2 ,user3

             创建用户及授权的命令

                       template1=#create user user2 with nosuperuser nocreatedb  password '123456a' ;

                       template1=# create user user3 with nosuperuser nocreatedb encrypted  password '123456a' ;

             然后管理员登陆数据库testdb,使得user2,user3可以访问表test1;

                       testdb=# GRANT all on table test1 to user2;

                       testdb=# GRANT all on table test1 to user3;

             测试password方式

                       服务端配置文件

                                host    testdb  user2   10.47.0.153/32  password

              host    testdb  user3   10.47.0.153/32  password

                       客户端代码

                                String url = "jdbc:postgresql://10.110.18.241/testdb";

                       Connection conn = DriverManager.getConnection(url, "user2", "123456a");

                       测试结果

                                User2,user3都连接数据库成功。

                      

             测试md5方式

                      服务端配置文件

                                host    testdb  user2   10.47.0.153/32  md5

              host    testdb  user3   10.47.0.153/32  md5

                       客户端代码

                                String url = "jdbc:postgresql://10.110.18.241/testdb";

                  Connection conn = DriverManager.getConnection(url, "user2", "123456a");

                       测试结果

                                User2,user3都连接数据库成功。

    分析:

         从测试情况看,服务端为数据库用户设置为password和md5,客户端密码为123456a都是可以的,那么password 和 md5 两种情况的区别在哪里呢?

         抓取了两种情况时的网络通信数据包,发现在运行时password网络传输的是明文,而md5方式网络传输的是md5编码后的密码。客户端程序是完全一样的。Md5避免了从网络抓包获取到明文的密码。

                      

           Password

                  PostgreSQL

        Type: Password message

        Length: 12

        Password: 123456a

     

           Md5

                 PostgreSQL

        Type: Password message

        Length: 40

        Password: md52a2922ec50be4efc34ba50cc1cc190e2

      如果网络通信使用了SSL,那么直接使用password也是安全的。

     从PostgreSQL8.4 中有说明 However, md5 cannot be used with the db_user_namespace Feature 。

  • 相关阅读:
    [数学-构造矩阵]NEFU 1113
    设计模式【1】:原型模式【创建对象】
    XML(五)dom4j增删改查
    小规则让你写出美丽又高效的程序
    jQuery源代码解析(3)—— ready载入、queue队列
    cocos2d-Lua02Lua面向对象
    在Linux下用make指令编译进度条程序。
    JS两日期相减
    java debugger
    tomcat server.xml
  • 原文地址:https://www.cnblogs.com/fangjx/p/6396109.html
Copyright © 2020-2023  润新知