from tornado.web import url

from .handlers import AuthHandler, CompleteHandler, DisconnectHandler


SOCIAL_AUTH_ROUTES = [
    url(r'/login/(?P<backend>[^/]+)/?', AuthHandler, name='begin'),
    url(r'/complete/(?P<backend>[^/]+)/?', CompleteHandler, name='complete'),
    url(r'/disconnect/(?P<backend>[^/]+)/?', DisconnectHandler,
        name='disconnect'),
    url(r'/disconnect/(?P<backend>[^/]+)/(?P<association_id>\d+)/?',
        DisconnectHandler, name='disconect_individual'),
]

from tornado.web import url

from .handlers import AuthHandler, CompleteHandler, DisconnectHandler


SOCIAL_AUTH_ROUTES = [
    url(r'/login/(?P<backend>[^/]+)/?', AuthHandler, name='begin'),
    url(r'/complete/(?P<backend>[^/]+)/', CompleteHandler, name='complete'),
    url(r'/disconnect/(?P<backend>[^/]+)/?', DisconnectHandler,
        name='disconnect'),
    url(r'/disconnect/(?P<backend>[^/]+)/(?P<association_id>\d+)/?',
        DisconnectHandler, name='disconect_individual'),
]

Fix redirect_uri issue with tornado reversed url
Fix redirect_uri issue with tornado reversed url

When reversing URLs, tornado doesn't interpret the regex optional symbol
'?'. This causes the redirect_uri to be
https://example.com/complete/mybackend/? with the question mark
appended. Some providers will simply append to this uri, causing URLs
like https://example.com/complete/mybackend/??code=.... with two
question marks. This makes the interpretation of the query string fail.

The provider in this case is
https://github.com/juanifioren/django-oidc-provider. Arguably that
library should be smarter in constructing the redirection, but removing
the question mark from the uri solves these kind of issues.

Alternatively we could strip the question mark from the uri in the
tornado strategy, but this seemed simpler.
