Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_code_challenge():
sess = AsyncOAuth2Client('foo', code_challenge_method='S256')
url = 'https://example.com/authorize'
auth_url, _ = sess.create_authorization_url(
url, code_verifier=generate_token(48))
assert 'code_challenge=' in auth_url
assert 'code_challenge_method=S256' in auth_url
def generate_client_id(self):
"""Generate ``client_id`` value. Developers MAY rewrite this method
to use their own way to generate ``client_id``.
"""
return generate_token(42)
def create_digital_user_code():
base = '0123456789'
return '-'.join([
generate_token(3, base),
generate_token(3, base),
generate_token(3, base),
])
def generate_device_code(self):
"""A method to generate ``device_code`` value for device authorization
endpoint. This method will generate a random string of 42 characters.
Developers can rewrite this method to create their own ``device_code``.
"""
return generate_token(42)
def token_generator(*args, **kwargs):
return generate_token(length)
return token_generator
def login():
if current_app.config['SKIP_LOGIN']:
payload = {'error': None, 'token': app_token_from_dummy()}
return render_template('login_result.html', payload=payload)
session['oidc.nonce'] = nonce = generate_token(20)
return oauth.oidc.authorize_redirect(
url_for('.login_oauth_oidc', _external=True), nonce=nonce
)
def create_authorization_code(self, client, grant_user, request):
code = generate_token(48)
data = dict(
code=code,
client_id=client.client_id,
redirect_uri=request.redirect_uri,
scope=request.scope,
user_id=grant_user.get_user_id(),
)
key = key_tpl.format(code, client.client_id)
cache.set(key, data, timeout=600)
return code
def create_string_user_code():
base = 'BCDFGHJKLMNPQRSTVWXZ'
return '-'.join([generate_token(4, base), generate_token(4, base)])