密码是否存储在keystone的密码表中,如果是,密码如何映射用户的密码?

时间:2017-10-27 07:21:38

标签: openstack

用户的密码在哪里存储?

我在keystone的用户表中找不到:

enter image description here

但我可以在keystone的密码表中找到:

enter image description here

密码是否映射了用户的密码?

我的问题是:

密码是否存储在keystone的密码表中?如果是,密码如何映射用户的密码? 密码加密了吗?我从未见过这种类型的密码。

我从未见过这种类型的密码。因为我使用openstacksdk注册一个项目和用户,我无法登录。我不知道为什么。所以,我想在这里了解一下。

我的项目的django代码如下:使用openstacksdk注册:

def register(request):

    if request.method == 'GET':
        return render(request, 'frontend/register.html')
    elif request.method == 'POST':

        username = request.POST.get('username')
        password = request.POST.get('password')
        phone = request.POST.get('phone')
        email = request.POST.get('email')
        usertype = 1

        app_user_params = {

            "username":username,
            "password":hashlib.sha1(password).hexdigest(), # sha1加密
            "phone":phone,
            "email":email,
            "usertype":usertype
        }

        user_form = UserMF(app_user_params)

        if user_form.is_valid():

            obj_user = models.User.objects.filter(username=username)
            obj_phone = models.User.objects.filter(phone=phone)
            obj_email = models.User.objects.filter(email=email)


            # 使用admin用户创建project和user

            from openstack import connection

            connection = connection.Connection(**settings.ADMIN_OPENRC)

            admin_conn = OpenstackConn.OpenstackAdminConn()
            admin_conn.admin_conn = connection

            # 创建项目(先创建项目,再创建用户)
            project_params = {
                "description":username+"'s project",
                "is_domain":False,
                "enable":False,  # I set True still has this issue.
                "name":username,  # 给的是用户名,也是唯一的
            }

            try:
                new_project = admin_conn.admin_conn.identity.create_project(**project_params)  # create_project

                print (new_project, new_project.id, "new project created")
            except Exception as e:
                print (e.message)
                return HttpResponse(json.dumps({'status_code':0,'info':e.message.encode('utf-8')}))

            # 创建 openstack_cloud user
            user_params = {
                "default_project_id":new_project.id,
                "email":email,
                "enabled":False,
                "name":username,
                "password":password
            }

            try:
                new_user = admin_conn.admin_conn.identity.create_user(**user_params)
                print (new_user, new_user.id, "new user created")
            except Exception as e:
                admin_conn.admin_conn.identity.delete_project(new_project)
                print (e.message)
                return HttpResponse(json.dumps({'status_code': 0, 'info': e.message.encode('utf-8')}))

我不知道我是否写错,或者密码会加密。

修改-1

我打印新创建的用户和user.id:

(openstack.identity.v3.user.User(name=liaodalin15, links={u'self': u'http://controller:5000/v3/users/66c60156d0f24a118df54f19e2705aaf'}, enabled=False, domain_id=default, email=xxxxxxxxx@126.com, default_project_id=a829eda8c4de479d8ca5c3a4335c793a, password=liaodalin15, id=66c60156d0f24a118df54f19e2705aaf, password_expires_at=None), u'66c60156d0f24a118df54f19e2705aaf')

Seems the password did now encrypt.  Does this should encrypt by ourself? 

1 个答案:

答案 0 :(得分:1)

最后,我想出了问题:

enter image description here

因为使用openstacksdk创建用户默认是禁用的,所以我应该这样做。