コード例 #1
0
    def last_modified_by_id(cls):
        """Declare the last_modified_by_id field.

        :param (object) cls
        :return db.Column
        """
        return db.Column(db.Integer, db.ForeignKey('user.id'))
コード例 #2
0
    def creator_id(cls):
        """Declare the creator_id field.

        :param (object) cls
        :return db.Column
        """
        return db.Column(db.Integer, db.ForeignKey('user.id'))
コード例 #3
0
class Grant(db.Model):
    """Grant model definition.

    The Grant databse table definition for handling OAuth authentication

    :param object db.Model: SQLAlchemy declarative base

    See the official Flask SQLAlchemy documentation for more information
    https://pythonhosted.org/Flask-SQLAlchemy/models.html
    """

    id = db.Column(db.Integer, primary_key=True)

    user_id = db.Column(db.Integer, db.ForeignKey('user.id',
                                                  ondelete='CASCADE'))
    user = db.relationship('User')

    client_id = db.Column(db.String,
                          db.ForeignKey('client.client_id'),
                          nullable=False)
    client = db.relationship('Client')

    code = db.Column(db.String, index=True, nullable=False)

    redirect_uri = db.Column(db.String)
    expires = db.Column(db.DateTime)

    _scopes = db.Column(db.String)

    def delete(self):
        """Remove the Grant from the database table.

        :param object self: Grant class
        """
        db.session.delete(self)
        db.session.commit()
        return self

    @property
    def scopes(self):
        """Define how scopes are displayed."""
        if self._scopes:
            return self._scopes.split()
        return []
コード例 #4
0
class Token(db.Model):
    """Token database definition.

    :param object db.Model: SQLAlchemy declarative base

    See the official Flask SQLAlchemy documentation for more information
    https://pythonhosted.org/Flask-SQLAlchemy/models.html
    """

    __tablename__ = 'token'
    __table_args__ = {'extend_existing': True}

    id = db.Column(db.Integer, primary_key=True)

    client_id = db.Column(db.String,
                          db.ForeignKey('client.client_id'),
                          nullable=False)
    client = db.relationship('Client')

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User')

    token_type = db.Column(db.String)

    access_token = db.Column(db.String, unique=True)
    refresh_token = db.Column(db.String, unique=True)

    expires = db.Column(db.DateTime)
    _scopes = db.Column(db.String)

    @property
    def scopes(self):
        """Define how scopes should be displayed."""
        if self._scopes:
            return self._scopes.split()
        return []
コード例 #5
0
class Client(db.Model):
    """Client model definition.

    Setup the client database table definition for handling OAuth
    authentication

    :param object db.Model: SQLAlchemy base declarative

    See the official Flask SQLAlchemy documetation for more information
    https://pythonhosted.org/Flask-SQLAlchemy/models.html
    """

    application_name = db.Column(db.Text)

    client_id = db.Column(db.String, primary_key=True)
    client_secret = db.Column(db.String, nullable=False)

    user_id = db.Column(db.ForeignKey('user.id'))
    user = db.relationship('User')

    _redirect_uris = db.Column(db.String)
    _default_scopes = db.Column(db.String)

    @property
    def client_type(self):
        """Define the default client type."""
        return 'public'

    @property
    def redirect_uris(self):
        """Define how redirect_uris are displayed."""
        if self._redirect_uris:
            return self._redirect_uris.split()
        return []

    @property
    def default_redirect_uri(self):
        """Select default redirect_uri."""
        return self.redirect_uris[0]

    @property
    def default_scopes(self):
        """Define how scopes are displayed."""
        if self._default_scopes:
            return self._default_scopes.split()
        return []
コード例 #6
0
from rith.schema.role import Role
"""User Roles schema definition.

These tables are necessary to perform our many to many relationships

@see https://pythonhosted.org/Flask-SQLAlchemy/models.html\
      #many-to-many-relationships
   This documentation is specific to Flask using sqlalchemy

@see http://docs.sqlalchemy.org/en/rel_0_9/orm/relationships.html\
      #relationships-many-to-many
   This documentation covers SQLAlchemy
"""
user_roles = db.Table('user_roles',
                      db.Column('user_id', db.Integer,
                                db.ForeignKey('user.id')),
                      db.Column('role_id', db.Integer,
                                db.ForeignKey('role.id')),
                      extend_existing=True)


class User(db.Model, UserMixin):
    """User schema definition.

    The `User` database table definition used throughout the system to
    identify, authenticate, and manage system users

    @param (object) db.Model
    @param (object) UserMixin
    """
    """Database table details.