示例#1
0
class RevocationEvent(sql.ModelBase, sql.ModelDictMixin):
    __tablename__ = 'revocation_event'
    attributes = revoke_model.REVOKE_KEYS

    # The id field is not going to be exposed to the outside world.
    # It is, however, necessary for SQLAlchemy.
    id = sql.Column(sql.Integer, primary_key=True, nullable=False)
    domain_id = sql.Column(sql.String(64))
    project_id = sql.Column(sql.String(64))
    user_id = sql.Column(sql.String(64))
    role_id = sql.Column(sql.String(64))
    trust_id = sql.Column(sql.String(64))
    consumer_id = sql.Column(sql.String(64))
    access_token_id = sql.Column(sql.String(64))
    issued_before = sql.Column(sql.DateTime(), nullable=False, index=True)
    expires_at = sql.Column(sql.DateTime())
    revoked_at = sql.Column(sql.DateTime(), nullable=False, index=True)
    audit_id = sql.Column(sql.String(32))
    audit_chain_id = sql.Column(sql.String(32))
    __table_args__ = (
        sql.Index('ix_revocation_event_project_id_issued_before', 'project_id',
                  'issued_before'),
        sql.Index('ix_revocation_event_user_id_issued_before', 'user_id',
                  'issued_before'),
        sql.Index('ix_revocation_event_audit_id_issued_before', 'audit_id',
                  'issued_before'),
    )
示例#2
0
class TokenModel(sql.ModelBase, sql.DictBase):
    __tablename__ = 'token'
    attributes = ['id', 'expires']
    id = sql.Column(sql.String(64), primary_key=True)
    expires = sql.Column(sql.DateTime(), default=None)
    extra = sql.Column(sql.JsonBlob())
    valid = sql.Column(sql.Boolean(), default=True)
示例#3
0
class ResetProfile(sql.ModelBase, sql.ModelDictMixin):
    __tablename__ = 'user_registration_reset_profile'
    attributes = ['id', 'user_id', 'expires_at', 'reset_token']
    id = sql.Column(sql.String(64), primary_key=True, nullable=False)
    user_id = sql.Column(sql.String(64), nullable=False, index=True)
    expires_at = sql.Column(sql.DateTime(), nullable=False)
    reset_token = sql.Column(sql.String(64), nullable=False, index=True)
示例#4
0
class RevocationEvent(sql.ModelBase, sql.ModelDictMixin):
    __tablename__ = 'revocation_event'
    attributes = model.REVOKE_KEYS

    # The id field is not going to be exposed to the outside world.
    # It is, however, necessary for SQLAlchemy.
    id = sql.Column(sql.String(64), primary_key=True)
    domain_id = sql.Column(sql.String(64))
    project_id = sql.Column(sql.String(64))
    user_id = sql.Column(sql.String(64))
    role_id = sql.Column(sql.String(64))
    trust_id = sql.Column(sql.String(64))
    consumer_id = sql.Column(sql.String(64))
    access_token_id = sql.Column(sql.String(64))
    issued_before = sql.Column(sql.DateTime(), nullable=False)
    expires_at = sql.Column(sql.DateTime())
    revoked_at = sql.Column(sql.DateTime(), nullable=False)
示例#5
0
class ActivationProfile(sql.ModelBase, sql.ModelDictMixin):
    __tablename__ = 'user_registration_activation_profile'
    attributes = ['id', 'user_id', 'expires_at', 'activation_key']
    id = sql.Column(sql.String(64), primary_key=True, nullable=False)
    user_id = sql.Column(sql.String(64), nullable=False, index=True)
    project_id = sql.Column(sql.String(64), nullable=False, index=True)
    cloud_project_id = sql.Column(sql.String(64), nullable=False, index=True)
    expires_at = sql.Column(sql.DateTime(), nullable=False)
    activation_key = sql.Column(sql.String(64), nullable=False, index=True)
示例#6
0
class TokenModel(sql.ModelBase, sql.DictBase):
    __tablename__ = 'token'
    attributes = ['id', 'expires', 'user_id', 'trust_id']
    id = sql.Column(sql.String(64), primary_key=True)
    expires = sql.Column(sql.DateTime(), default=None)
    extra = sql.Column(sql.JsonBlob())
    valid = sql.Column(sql.Boolean(), default=True, nullable=False)
    user_id = sql.Column(sql.String(64))
    trust_id = sql.Column(sql.String(64))
    __table_args__ = (sql.Index('ix_token_expires', 'expires'),
                      sql.Index('ix_token_expires_valid', 'expires', 'valid'))
示例#7
0
class SPasswordModel(sql.ModelBase, sql.ModelDictMixinWithExtras):
    __tablename__ = 'spassword'
    attributes = [
        'user_id', 'user_name', 'domain_id', 'creation_time', 'login_attempts',
        'last_login_attempt_time', 'sndfa', 'sndfa_last', 'sndfa_code',
        'sndfa_time_code', 'sndfa_email', 'sndfa_email_code'
    ]
    user_id = sql.Column(sql.String(64), primary_key=True)
    user_name = sql.Column(sql.String(255), default=None)
    domain_id = sql.Column(sql.String(64), default=None)
    creation_time = sql.Column(sql.DateTime(), default=None)
    login_attempts = sql.Column(sql.Integer, default=0)
    last_login_attempt_time = sql.Column(sql.DateTime(), default=None)
    # bad_attempts
    extra = sql.Column(sql.JsonBlob())
    # sndfa
    sndfa = sql.Column(sql.Boolean(), default=False)
    sndfa_last = sql.Column(sql.DateTime(), default=None)
    sndfa_code = sql.Column(sql.String(32), default=None)
    sndfa_time_code = sql.Column(sql.DateTime(), default=None)
    sndfa_email = sql.Column(sql.Boolean(), default=False)
    sndfa_email_code = sql.Column(sql.String(32), default=None)
示例#8
0
def upgrade(migrate_engine):
    # Upgrade operations go here. Don't create your own engine; bind
    # migrate_engine to your metadata
    meta = MetaData()
    meta.bind = migrate_engine

    sql.ModelBase.metadata.create_all(migrate_engine)

    token = Table('token', meta, Column('id', sql.String(64),
                                        primary_key=True),
                  Column('expires', sql.DateTime()),
                  Column('extra', sql.JsonBlob()))

    token.create(migrate_engine, checkfirst=True)
示例#9
0
class ConsumerCredentials(sql.ModelBase, sql.DictBase):
    __tablename__ = 'consumer_credentials_oauth2'
    attributes = ['id', 'user_id', 'client_id', 'redirect_uri',
                'response_type', 'state', 'created_at', 'extra']
    
    id = sql.Column(sql.String(64), primary_key=True, nullable=False)
    user_id = sql.Column(sql.String(64), index=True, nullable=False)
    client_id = sql.Column(sql.String(64), sql.ForeignKey('consumer_oauth2.id'),
                             nullable=False, index=True)
    redirect_uri = sql.Column(sql.String(256), nullable=False)
    response_type = sql.Column(VALID_RESPONSE_TYPES, nullable=False)
    state = sql.Column(sql.String(256), nullable=True)
    created_at = sql.Column(sql.DateTime(), default=None, nullable=False)
    extra = sql.Column(sql.JsonBlob(), nullable=True)
示例#10
0
class TokenModel(sql.ModelBase, sql.DictBase):
    __tablename__ = 'token'
    id = sql.Column(sql.String(64), primary_key=True)
    expires = sql.Column(sql.DateTime(), default=None)
    extra = sql.Column(sql.JsonBlob())

    @classmethod
    def from_dict(cls, token_dict):
        # shove any non-indexed properties into extra
        extra = copy.deepcopy(token_dict)
        data = {}
        for k in ('id', 'expires'):
            data[k] = extra.pop(k, None)
        data['extra'] = extra
        return cls(**data)

    def to_dict(self):
        out = copy.deepcopy(self.extra)
        out['id'] = self.id
        out['expires'] = self.expires
        return out