Commit 2d695ae0 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

astakos: Generate tokens without trailing equal signs

Strip padding ("=") introduced during the base64 encoding.
Update token examples in docs.
parent f6cfc6e4
......@@ -341,7 +341,7 @@ def _mock_request(new_requests):
# ----------------------------
# Local users
token_1 = "skzleaFlBl+fasFdaf24sx=="
token_1 = "skzleaFlBl+fasFdaf24sx"
user_1 = \
{"username": "user1@example.com",
"auth_token_created": 1359386939000,
......@@ -370,7 +370,7 @@ user_1 = \
"display_name": "Storage Space",
"name": "pithos+.diskspace"}]}
token_2 = "fasdfDSFdf98923DF+sdfk=="
token_2 = "fasdfDSFdf98923DF+sdfk"
user_2 = \
{"username": "user2@example.com",
"auth_token_created": 1358386938997,
......@@ -581,7 +581,7 @@ class TestCallAstakos(unittest.TestCase):
# ----------------------------------
# Test the response we get if we send invalid token
def _invalid_token(self, pool):
token = "skaksaFlBl+fasFdaf24sx=="
token = "skaksaFlBl+fasFdaf24sx"
_mock_request([_request_ok])
try:
client = AstakosClient("https://example.com", use_pool=pool)
......@@ -737,7 +737,7 @@ class TestAuthenticate(unittest.TestCase):
# ----------------------------------
# Test the response we get for invalid token
def _invalid_token(self, pool):
token = "skaksaFlBl+fasFdaf24sx=="
token = "skaksaFlBl+fasFdaf24sx"
_mock_request([_request_ok])
try:
client = AstakosClient("https://example.com", use_pool=pool)
......@@ -824,7 +824,7 @@ class TestDisplayNames(unittest.TestCase):
def test_invalid_token(self):
"""Test the response we get for invalid token (without pool)"""
global user_1
token = "skaksaFlBl+fasFdaf24sx=="
token = "skaksaFlBl+fasFdaf24sx"
_mock_request([_request_ok])
try:
client = AstakosClient("https://example.com")
......@@ -889,7 +889,7 @@ class TestGetUUIDs(unittest.TestCase):
def test_invalid_token(self):
"""Test the response we get for invalid token (using pool)"""
global user_1
token = "skaksaFlBl+fasFdaf24sx=="
token = "skaksaFlBl+fasFdaf24sx"
_mock_request([_request_ok])
try:
client = AstakosClient("https://example.com")
......
......@@ -39,7 +39,7 @@ demonstrates how to get user's info using ``astakosclient``.
from astakosclient import AstakosClient
client = AstakosClient("https://accounts.example.com")
user_info = client.get_user_info("UQpYas7ElzWGD5yCcEXtjw==")
user_info = client.get_user_info("UQpYas7ElzWGD5yCcEXtjw")
print user_info['username']
Another example where we ask for the username of a user with UUID:
......@@ -50,7 +50,7 @@ Another example where we ask for the username of a user with UUID:
from astakosclient import AstakosClient
client = AstakosClient("https://accounts.example.com")
username = client.get_username("UQpYas7ElzWGD5yCcEXtjw==",
username = client.get_username("UQpYas7ElzWGD5yCcEXtjw",
"b3de8eb0-3958-477e-als9-789af8dd352c")
print username
......
......@@ -330,7 +330,7 @@ Example request:
{
"auth":{
"token":{
"id":"CDEe2k0T/HdiJWBMMbHyOA=="
"id":"CDEe2k0T/HdiJWBMMbHyOA"
},
"tenantName":"c18088be-16b1-4263-8180-043c54e22903"
}
......@@ -344,7 +344,7 @@ or
"auth":{
"passwordCredentials":{
"username":"c18088be-16b1-4263-8180-043c54e22903",
"password":"CDEe2k0T/HdiJWBMMbHyOA=="
"password":"CDEe2k0T/HdiJWBMMbHyOA"
},
"tenantName":"c18088be-16b1-4263-8180-043c54e22903"
}
......@@ -406,7 +406,7 @@ Example json response:
"type": "identity"}],
"token": {
"expires": "2013-06-19T15:23:59.975572+00:00",
"id": "CDEe2k0T/HdiJWBMMbHyOA==",
"id": "CDEe2k0T/HdiJWBMMbHyOA",
"tenant": {"id": "c18088be-16b1-4263-8180-043c54e22903",
"name": "Firstname Lastname"}},
"user": {
......@@ -423,7 +423,7 @@ Example xml response:
<access xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://docs.openstack.org/identity/api/v2.0">
<token id="CDEe2k0T/HdiJWBMMbHyOA==" expires="2013-06-19T15:23:59.975572+00:00">
<token id="CDEe2k0T/HdiJWBMMbHyOA" expires="2013-06-19T15:23:59.975572+00:00">
<tenant id="c18088be-16b1-4263-8180-043c54e22903" name="Firstname Lastname" />
</token>
<user id="c18088be-16b1-4263-8180-043c54e22903" name="Firstname Lastname">
......
......@@ -867,7 +867,7 @@ this options:
PITHOS_BACKEND_DB_CONNECTION = 'postgresql://synnefo:example_passw0rd@node1.example.com:5432/snf_pithos'
PITHOS_BACKEND_BLOCK_PATH = '/srv/pithos/data'
PITHOS_SERVICE_TOKEN = 'pithos_service_token22w=='
PITHOS_SERVICE_TOKEN = 'pithos_service_token22w'
# Set to False if astakos & pithos are on the same host
#PITHOS_PROXY_USER_SERVICES = True
......@@ -1707,7 +1707,7 @@ Edit ``/etc/synnefo/20-snf-cyclades-app-api.conf``:
# Set to False if astakos & cyclades are on the same host
CYCLADES_PROXY_USER_SERVICES = False
CYCLADES_SERVICE_TOKEN = 'cyclades_service_token22w=='
CYCLADES_SERVICE_TOKEN = 'cyclades_service_token22w'
The ``ASTAKOS_BASE_URL`` denotes the Astakos endpoint for Cyclades,
which is used for all user management, including authentication.
......
......@@ -95,7 +95,7 @@ inf = float('inf')
def generate_token():
s = os.urandom(32)
return base64.urlsafe_b64encode(s)
return base64.urlsafe_b64encode(s).rstrip('=')
class Component(models.Model):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment