Beispiel #1
0
    def POST(self):
        data = self.checked_data()
        try:
            if "passwordCredentials" in data["auth"]:
                if not validate_password_credentials(**data["auth"]["passwordCredentials"]):
                    raise self.http(401)
            elif "token" in data["auth"]:
                if not validate_token(data["auth"]["token"]["id"]):
                    raise self.http(401)
            else:
                raise self.http(400)
        except (KeyError, TypeError):
            raise self.http(400)

        token = generate_token()

        return {
            "access": {
                "token": {
                    "issued_at": "2012-07-10T13:37:58.708765",
                    "expires": "2012-07-10T14:37:58Z",
                    "id": token,
                    "tenant": {"description": None, "enabled": True, "id": "12345", "name": "admin"},
                },
                "serviceCatalog": [],
                "user": {
                    "username": "******",
                    "roles_links": [],
                    "id": "9876",
                    "roles": [{"name": "admin"}],
                    "name": "admin",
                },
                "metadata": {"is_admin": 0, "roles": ["4567"]},
            }
        }
Beispiel #2
0
    def POST(self):
        data = self.checked_data()
        try:
            if 'passwordCredentials' in data['auth']:
                if not validate_password_credentials(
                        **data['auth']['passwordCredentials']):
                    raise self.http(401)
            elif 'token' in data['auth']:
                if not validate_token(data['auth']['token']['id']):
                    raise self.http(401)
            else:
                raise self.http(400)
        except (KeyError, TypeError):
            raise self.http(400)

        token = generate_token()

        return {
            "access": {
                "token": {
                    "issued_at": "2012-07-10T13:37:58.708765",
                    "expires": "2012-07-10T14:37:58Z",
                    "id": token,
                    "tenant": {
                        "description": None,
                        "enabled": True,
                        "id": "12345",
                        "name": "admin"
                    }
                },
                "serviceCatalog": [],
                "user": {
                    "username": "******",
                    "roles_links": [],
                    "id": "9876",
                    "roles": [{
                        "name": "admin"
                    }],
                    "name": "admin"
                },
                "metadata": {
                    "is_admin": 0,
                    "roles": ["4567"]
                }
            }
        }
Beispiel #3
0
    def POST(self):
        data = self.checked_data()
        try:
            if 'password' in data['auth']['identity']['methods']:
                if not validate_password_credentials(
                        data['auth']['identity']['password']['user']['name'],
                        data['auth']['identity']['password']['user']
                    ['password']):
                    raise self.http(401)
            elif 'token' in data['auth']['identity']['methods']:
                if not validate_token(data['auth']['identity']['token']['id']):
                    raise self.http(401)
            else:
                raise self.http(400)
        except (KeyError, TypeError):
            raise self.http(400)

        web.header('X-Subject-Token', generate_token())

        return self._get_token_info()
Beispiel #4
0
    def POST(self):
        data = self.checked_data()
        try:
            if 'password' in data['auth']['identity']['methods']:
                if not validate_password_credentials(
                    data['auth']['identity']['password']['user']['name'],
                    data['auth']['identity']['password']['user']['password']
                ):
                    raise self.http(401)
            elif 'token' in data['auth']['identity']['methods']:
                if not validate_token(data['auth']['identity']['token']['id']):
                    raise self.http(401)
            else:
                raise self.http(400)
        except (KeyError, TypeError):
            raise self.http(400)

        web.header('X-Subject-Token', generate_token())

        return self._get_token_info()