Merge branch 'PR63'

This commit is contained in:
MasterRoshan 2019-03-26 13:10:56 -04:00
commit d325ea430e
5 changed files with 14 additions and 8 deletions

View file

@ -1,9 +1,10 @@
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
install:
- python setup.py install
# command to run tests

View file

@ -96,7 +96,10 @@ def login_required(function):
@wraps(function)
def wrap(*args, **kwargs):
if 'CAS_USERNAME' not in flask.session:
flask.session['CAS_AFTER_LOGIN_SESSION_URL'] = flask.request.path
flask.session['CAS_AFTER_LOGIN_SESSION_URL'] = (
flask.request.script_root +
flask.request.full_path
)
return login()
else:
return function(*args, **kwargs)

View file

@ -35,7 +35,7 @@ def login():
redirect_url = create_cas_login_url(
current_app.config['CAS_SERVER'],
current_app.config['CAS_LOGIN_ROUTE'],
flask.url_for('.login', _external=True))
flask.url_for('.login', origin=flask.session.get('CAS_AFTER_LOGIN_SESSION_URL'), _external=True))
if 'ticket' in flask.request.args:
flask.session[cas_token_session_key] = flask.request.args['ticket']
@ -45,6 +45,8 @@ def login():
if validate(flask.session[cas_token_session_key]):
if 'CAS_AFTER_LOGIN_SESSION_URL' in flask.session:
redirect_url = flask.session.pop('CAS_AFTER_LOGIN_SESSION_URL')
elif flask.request.args.get('origin'):
redirect_url = flask.request.args['origin']
else:
redirect_url = flask.url_for(
current_app.config['CAS_AFTER_LOGIN'])
@ -71,7 +73,7 @@ def logout():
if cas_attributes_session_key in flask.session:
del flask.session[cas_attributes_session_key]
if(current_app.config['CAS_AFTER_LOGOUT'] != None):
if(current_app.config['CAS_AFTER_LOGOUT'] is not None):
redirect_url = create_cas_logout_url(
current_app.config['CAS_SERVER'],
current_app.config['CAS_LOGOUT_ROUTE'],
@ -102,7 +104,7 @@ def validate(ticket):
cas_validate_url = create_cas_validate_url(
current_app.config['CAS_SERVER'],
current_app.config['CAS_VALIDATE_ROUTE'],
flask.url_for('.login', _external=True),
flask.url_for('.login', origin=flask.session.get('CAS_AFTER_LOGIN_SESSION_URL'), _external=True),
ticket)
current_app.logger.debug("Making GET request to {0}".format(

View file

@ -46,7 +46,7 @@ if __name__ == "__main__":
.. code:: python
from flask.ext.cas import CAS
from flask_cas import CAS
CAS(app)

View file

@ -7,8 +7,8 @@ try:
except ImportError:
import unittest.mock as mock
from flask.ext.cas import routing
from flask.ext.cas import CAS
from flask_cas import routing
from flask_cas import CAS
class test_routing(unittest.TestCase):