本文整理汇总了Python中werkzeug.security.gen_salt方法的典型用法代码示例。如果您正苦于以下问题:Python security.gen_salt方法的具体用法?Python security.gen_salt怎么用?Python security.gen_salt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.security
的用法示例。
在下文中一共展示了security.gen_salt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import gen_salt [as 别名]
def post(self, args):
"""
Create a new OAuth2 Client.
Essentially, OAuth2 Client is a ``client_id`` and ``client_secret``
pair associated with a user.
"""
with api.commit_or_abort(
db.session,
default_error_message="Failed to create a new OAuth2 client."
):
# TODO: reconsider using gen_salt
new_oauth2_client = OAuth2Client(
user_id=current_user.id,
client_id=security.gen_salt(40),
client_secret=security.gen_salt(50),
**args
)
db.session.add(new_oauth2_client)
return new_oauth2_client
示例2: __init__
# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import gen_salt [as 别名]
def __init__(self, app, evalex=False, request_key='werkzeug.request',
console_path='/console', console_init_func=None,
show_hidden_frames=False, lodgeit_url=None):
if lodgeit_url is not None:
from warnings import warn
warn(DeprecationWarning('Werkzeug now pastes into gists.'))
if not console_init_func:
console_init_func = dict
self.app = app
self.evalex = evalex
self.frames = {}
self.tracebacks = {}
self.request_key = request_key
self.console_path = console_path
self.console_init_func = console_init_func
self.show_hidden_frames = show_hidden_frames
self.secret = gen_salt(20)
示例3: __init__
# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import gen_salt [as 别名]
def __init__(self, app, evalex=False, request_key='werkzeug.request',
console_path='/console', console_init_func=None,
show_hidden_frames=False, lodgeit_url=None,
pin_security=True, pin_logging=True):
if lodgeit_url is not None:
from warnings import warn
warn(DeprecationWarning('Werkzeug now pastes into gists.'))
if not console_init_func:
console_init_func = None
self.app = app
self.evalex = evalex
self.frames = {}
self.tracebacks = {}
self.request_key = request_key
self.console_path = console_path
self.console_init_func = console_init_func
self.show_hidden_frames = show_hidden_frames
self.secret = gen_salt(20)
self._failed_pin_auth = 0
self.pin_logging = pin_logging
if pin_security:
# Print out the pin for the debugger on standard out.
if os.environ.get('WERKZEUG_RUN_MAIN') == 'true' and \
pin_logging:
_log('warning', ' * Debugger is active!')
if self.pin is None:
_log('warning', ' * Debugger pin disabled. '
'DEBUGGER UNSECURED!')
else:
_log('info', ' * Debugger pin code: %s' % self.pin)
else:
self.pin = None
示例4: __init__
# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import gen_salt [as 别名]
def __init__(self, app, evalex=False, request_key='werkzeug.request',
console_path='/console', console_init_func=None,
show_hidden_frames=False, lodgeit_url=None,
pin_security=True, pin_logging=True):
if lodgeit_url is not None:
from warnings import warn
warn(DeprecationWarning('Werkzeug now pastes into gists.'))
if not console_init_func:
console_init_func = None
self.app = app
self.evalex = evalex
self.frames = {}
self.tracebacks = {}
self.request_key = request_key
self.console_path = console_path
self.console_init_func = console_init_func
self.show_hidden_frames = show_hidden_frames
self.secret = gen_salt(20)
self._failed_pin_auth = 0
self.pin_logging = pin_logging
if pin_security:
# Print out the pin for the debugger on standard out.
if os.environ.get('WERKZEUG_RUN_MAIN') == 'true' and \
pin_logging:
_log('warning', ' * Debugger is active!')
if self.pin is None:
_log('warning', ' * Debugger PIN disabled. '
'DEBUGGER UNSECURED!')
else:
_log('info', ' * Debugger PIN: %s' % self.pin)
else:
self.pin = None
示例5: post
# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import gen_salt [as 别名]
def post(self):
"""Creates a new user with your site admin authority.
We will send you an email of random password if don't specify password
explicitly.
:form username: The username of new user.
:form password: The optional password of new user.
:form email: The email of new user.
:<header Authorization: Huskar Token (See :ref:`token`)
:status 400: The username is used or the format is invalid.
:status 200: The new user is created successfully.
"""
g.auth.require_admin('only admin can add users')
username = request.form['username'].strip()
password = request.form.get('password', gen_salt(30))
is_generated_password = 'password' not in request.form
email = request.form['email'].strip()
validate_fields(user_schema, {'username': username, 'email': email})
user = User.get_by_name(username)
if user:
abort(400, u'{0} is used username'.format(username))
try:
user = User.create_normal(username, password, email,
is_active=True)
except NameOccupiedError:
abort(400, u'User %s has been archived' % username)
audit_log.emit(audit_log.types.CREATE_USER, user=user)
if is_generated_password:
deliver_email(EmailTemplate.SIGNUP, user.email, {
'username': user.username,
'password': password,
})
return api_response()
示例6: ensure
# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import gen_salt [as 别名]
def ensure(self):
user = (User.get_by_name(self.name) or
User.get_by_email(self.email))
if user is None:
password = gen_salt(30)
user = User.create_normal(
self.name, password, self.email, is_active=True)
deliver_email(EmailTemplate.SIGNUP, user.email, {
'username': user.username,
'password': password,
})
return user
示例7: create_app
# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import gen_salt [as 别名]
def create_app():
badge_list = []
form = CreateAppForm()
if form.validate_on_submit():
app = App(
application_id=gen_salt(10),
application_name=form.application_name.data,
application_description=form.application_description.data,
application_website=form.application_website.data,
user_id=current_user.id)
db.session.add(app)
db.session.flush()
item = Client(
client_id=gen_salt(40),
client_secret=gen_salt(50),
_default_scopes='verse chapter',
user_id=current_user.id,
app_id=app.application_id)
db.session.add(item)
db.session.commit()
send_email(
recipient=current_user.email,
subject='Application Successfully Registered',
template='account/email/confirm_app',
user=current_user._get_current_object(),
app_name=form.application_name.data)
flash('You application has been created.', 'success')
return redirect(
url_for('account.update_app', application_id=app.application_id))
return render_template(
'account/create_app.html',
user=current_user._get_current_object(),
form=form,
badge_list=badge_list)