예제 #1
0
def dummytoken(token, **kwargs):
    """Create a dummy token for dev."""
    session = context.get('session')
    Token.delete().where(Token.access_token == token).execute()
    Token.create(session=session.pk, access_token=token, expires_in=3600*24,
                 token_type='Bearer', scope='*')
    reporter.notice('Created token', token)
예제 #2
0
def dummytoken(**kwargs):
    """Create a dummy token for dev."""
    session = context.get('session')
    Token.delete().where(Token.access_token == 'token').execute()
    Token.create(session=session.id,
                 access_token="token",
                 expires_in=3600 * 24)
    report('Created token', 'token', report.NOTICE)
예제 #3
0
파일: auth.py 프로젝트: pjegouic/ban
def dummytoken(token, **kwargs):
    """Create a dummy token for dev."""
    session = context.get('session')
    Token.delete().where(Token.access_token == token).execute()
    Token.create(session=session.pk,
                 access_token=token,
                 expires_in=3600 * 24,
                 token_type='Bearer',
                 scope='*')
    reporter.notice('Created token', token)
예제 #4
0
def dummytoken(token, **kwargs):
    """Create a dummy token for dev."""
    session = context.get('session')
    Token.delete().where(Token.access_token == token).execute()
    Token.create(session=session.pk,
                 access_token=token,
                 expires_in=3600 * 24,
                 token_type='Bearer',
                 scopes="municipality_write postcode_write \
                 group_write housenumber_write position_write bal".split(),
                 status='dev')
    reporter.notice('Created token', token)
예제 #5
0
def invalidatetoken(client=None, user=None, **kwargs):
    """Invalidate a token.
    Provide at least a client or a user

    client   client_id or client_secret of an existing client
    user     username or email of an existing user
    """
    if not client and not user:
        helpers.abort("""Provide at least a client (client_id or client_secret)
             or a user (username or email)""")
    if user:
        user_inst = User.first((User.username == user) | (User.email == user))
        if not user_inst:
            return reporter.error('User not found', user)
        where_clause = (Session.user_id == user_inst.pk)
    else:
        client_inst = Client.first((Client.client_id == client)
                                   | (Client.client_secret == client))
        if not client_inst:
            return reporter.error('Client not found', user)
        where_clause = (Session.client_id == client_inst.pk)

    tokens = Token.select().join(Session).where(where_clause).where(
        Token.expires > utcnow())
    for token in tokens:
        token.expires = utcnow()
        token.save()
    reporter.notice('Invalidate {} tokens'.format(len(tokens)), tokens)
예제 #6
0
파일: auth.py 프로젝트: LaPosteSNA/ban
def dummytoken(**kwargs):
    """Create a dummy token for dev."""
    session = context.get('session')
    Token.delete().where(Token.access_token == 'token').execute()
    Token.create(session=session.id, access_token="token", expires_in=3600*24)
    report('Created token', 'token', report.NOTICE)