How to use the itsdangerous.URLSafeSerializer function in itsdangerous

To help you get started, we’ve selected a few itsdangerous examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AtelierSoude / OpenRepairPlatform / plateformeweb / views.py View on Github external
def cancel_reservation(request, token):
    s = URLSafeSerializer('some_secret_key', salt='cancel_reservation')
    ret = s.loads(token)
    event_id = ret['event_id']
    user_id = ret['user_id']
    event = Event.objects.get(pk=event_id)
    user = CustomUser.objects.get(pk=user_id)
    context = {'event': event, 'user': user}
    attendees = event.attendees.all()
    if user in attendees:
        event.attendees.remove(user)
        event.available_seats += 1
        event.save()
        return render(request, 'mail/cancel_ok.html', context)
    else:
        return render(request, 'mail/cancel_failed.html', context)
github openedoo / openedoo / openedoo / core / libs / tools.py View on Github external
def session_encode(string_input):
	data = (random_word(16)+"."+string_input+"."+random_word(16))
	s = urlsafe('generate:openedoo')
	b = s.dumps(data)
	return b
github kamalgill / flask-appengine-template / src / lib / flask_debugtoolbar / panels / sqlalchemy.py View on Github external
def query_signer():
    return itsdangerous.URLSafeSerializer(current_app.config['SECRET_KEY'],
                                          salt='fdt-sql-query')
github scragg0x / realms-wiki / realms / modules / auth / local / models.py View on Github external
def signer(salt):
        return URLSafeSerializer(current_app.config['SECRET_KEY'] + salt)
github LibraryBox-Dev / alexandria / bin / LibServer / __init__.py View on Github external
def sign_auth_path(next_path):
    """returns a URL-safe signed next_path"""
    # next_path must start with a /
    if not next_path.startswith('/'):
        abort(503)
    # sign the next_path
    notary = itsdangerous.URLSafeSerializer(app.secret_key)
    next_path_signed = notary.dumps(next_path)
    return url_for('authenticate', next=next_path_signed)
github AtelierSoude / OpenRepairPlatform / api / views.py View on Github external
def set_present(request):
    if request.method != 'POST':
        # TODO change this
        return HttpResponse("Circulez, il n'y a rien à voir")
    else:
        serial = URLSafeSerializer('some_secret_key',
                                    salt='presence')

        data = serial.loads(request.POST['idents'])
        event_id = data['event_id']
        user_id = data['user_id']

        person = CustomUser.objects.get(pk=user_id)
        event = Event.objects.get(pk=event_id)
        event.attendees.remove(person)
        event.presents.add(person)
        action.send(request.user, verb="a validé la présence de", action_object=person,  target=event)   

        return JsonResponse({'status': "OK", 'user_id': user_id})
github hustlzp / Flask-Boost / flask_boost / project / application / utils / security.py View on Github external
def encode(something):
    """Encode something with SECRET_KEY."""
    secret_key = current_app.config.get('SECRET_KEY')
    s = URLSafeSerializer(secret_key)
    return s.dumps(something)
github openaddresses / machine / openaddr / ci / webauth.py View on Github external
def unserialize(secret, data):
    return URLSafeSerializer(secret).loads(data)
github mgood / flask-debugtoolbar / flask_debugtoolbar / panels / sqlalchemy.py View on Github external
def query_signer():
    return itsdangerous.URLSafeSerializer(current_app.config['SECRET_KEY'],
                                          salt='fdt-sql-query')