Esempio n. 1
0
def rand_seed(seed):
    # type: (bytes) -> None
    """
    Equivalent to rand_add() when len(seed) == entropy.

    :param seed: added data (see description at rand_add)
    """
    m2.rand_seed(seed)  # pylint: disable=no-member
Esempio n. 2
0
def rand_seed(seed):
    # type: (bytes) -> None
    """
    Equivalent to rand_add() when len(seed) == entropy.

    :param seed: added data (see description at rand_add)
    """
    m2.rand_seed(seed)  # pylint: disable=no-member
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

import datetime
import pickle
import base64
import os
from M2Crypto import m2
from flask.sessions import SessionInterface, SessionMixin

m2.rand_seed(os.urandom(16))

def sessions_mongo(app):
    """Initialize the `app` for use with :class:`~MongoSessionInterface`
    
    The app is configured according to the configuration variables
    ``SESSION_MONGO_PREIX`` (prefix of :class:`~PyMongo` instance. Defaults 
    to "MONGO"), ``SESSION_MONGO_COLLECTION`` (name of Mongo collection 
    for sessions. Defaults to "sessions"). To set up session expiration 
    time use db.sessions.ensureIndex( { 'accessTime': 1 }, { 
    'expireAfterSeconds': 3600 } in your Mongo shell.
    
    :param flask.Flask app: the application to configure for use with
        :class:`~MongoSessionInterface`
    """
    if app is None: