Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

expose flask-login token-loader to use a custom token_loader #260

Closed
wants to merge 1 commit into from
Closed

expose flask-login token-loader to use a custom token_loader #260

wants to merge 1 commit into from

Conversation

ocean1
Copy link

@ocean1 ocean1 commented Jun 5, 2014

I need to create a custom token (also to avoid using md5 hash) and want to use all the goodies flask-security brings (it's tied with a web application which uses flask-security)
it's just a matter of exposing the token_loader decorator of flask_login.

an example is the following:

security = Security(Flask(__name__))

@security.token_loader
def api_token_loader(token):
    try:
        if token is not None:
            user = user_datastore.find_user(user_key=token)
            if user is not None:
                return user
    except:
        pass
    return AnonymousUser()

and the user token can be generated any way we desire (i.e. resorting to our favourite RNG and hashing algo)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) when pulling c8cfcdf on ocean1:custom_token_loader into faa9f65 on mattupstate:develop.

@ocean1 ocean1 closed this Jun 6, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants