Esempio n. 1
0
def get_userinfo():
    logger.debug("get_userinfo()")
    user_info = None
    session[SESSION_INSTANCE_SETTINGS_KEY][GET_NEW_TOKEN_URL] = ""

    if TokenUtil.is_valid_remote(TokenUtil.get_access_token(request.cookies),
                                 session[SESSION_INSTANCE_SETTINGS_KEY]):
        logger.debug("valid")
        user_info = TokenUtil.get_claims_from_token(
            TokenUtil.get_id_token(request.cookies))
    else:
        logger.debug("notvalid")
        session[SESSION_INSTANCE_SETTINGS_KEY][
            GET_NEW_TOKEN_URL] = get_oauth_authorize_url()
    return user_info
Esempio n. 2
0
    def decorated_function(*args, **kws):
        logger.debug("authenticated()")

        token = TokenUtil.get_access_token(request.cookies)
        # logger.debug("token: {0}".format(token))

        if TokenUtil.is_valid_remote(token,
                                     session[SESSION_INSTANCE_SETTINGS_KEY]):
            return f(*args, **kws)
        else:
            logger.debug("Access Denied")
            session[FROM_URI_KEY] = request.url.replace("http://", "https://")
            # change to different main
            return redirect(
                url_for("gbac_bp.gbac_login",
                        _external="True",
                        _scheme="https"))