Skip to content

Commit

Permalink
changed default character set for client_id and client_secret generat…
Browse files Browse the repository at this point in the history
…ors, fixes #167 #170
  • Loading branch information
masci committed Jan 7, 2015
1 parent 1425267 commit 4229300
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions oauth2_provider/generators.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import absolute_import
from __future__ import unicode_literals

from oauthlib.common import generate_client_id as oauthlib_generate_client_id
from oauthlib.common import UNICODE_ASCII_CHARACTER_SET

from .settings import oauth2_settings


CLIENT_ID_CHARACTER_SET = r'_-.:;=?!@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'


class BaseHashGenerator(object):
"""
All generators should extend this class overriding `.hash()` method.
Expand All @@ -20,13 +21,13 @@ def hash(self):
Generate a client_id without colon char as in http://tools.ietf.org/html/rfc2617#section-2
for Basic Authentication scheme
"""
client_id_charset = CLIENT_ID_CHARACTER_SET.replace(":", "")
return oauthlib_generate_client_id(length=40, chars=client_id_charset)
return oauthlib_generate_client_id(length=40, chars=UNICODE_ASCII_CHARACTER_SET)


class ClientSecretGenerator(BaseHashGenerator):
def hash(self):
return oauthlib_generate_client_id(length=oauth2_settings.CLIENT_SECRET_GENERATOR_LENGTH, chars=CLIENT_ID_CHARACTER_SET)
return oauthlib_generate_client_id(length=oauth2_settings.CLIENT_SECRET_GENERATOR_LENGTH,
chars=UNICODE_ASCII_CHARACTER_SET)


def generate_client_id():
Expand Down

0 comments on commit 4229300

Please sign in to comment.