def is_user_changing_own_key(self, req, user):
        admin_detail = self.get_admin_detail(req)
        if not admin_detail:
            # The user does not exist
            return False

        # If user is not admin/reseller_admin and x-auth-user-admin or
        # x-auth-user-reseller-admin headers are present in request, he may be
        # attempting to escalate himself as admin/reseller_admin!
        if '.admin' not in (g['name'] for g in admin_detail['groups']):
            if req.headers.get('x-auth-user-admin') == 'true' or \
                    req.headers.get('x-auth-user-reseller-admin') == 'true':
                        return False
        if '.reseller_admin' not in \
            (g['name'] for g in admin_detail['groups']) and \
                req.headers.get('x-auth-user-reseller-admin') == 'true':
                    return False

        return req.headers.get('x-auth-admin-user') == user and \
            self.credentials_match(admin_detail,
                                   req.headers.get('x-auth-admin-key'))
Check if the user is changing his own key.
dataset/ETHPy150Open openstack/swauth/swauth/middleware.py/Swauth.is_user_changing_own_key