Skip to content

Commit 6fef281

Browse files
committed
Rebased
Updated Azure to allow defining authorization_url_params Fix format for black Fixed some doc issues with Python Requests preventing the tests passing Revert "Fixed some doc issues with Python Requests preventing the tests passing" This reverts commit b9ae3f4.
1 parent 1f42014 commit 6fef281

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Changelog
77
to include the ``client_id`` in the OAuth token request.
88
* Removed Okta pre-set configuration, since it doesn't add any value over
99
using ``OAuth2ConsumerBlueprint`` directly.
10+
* Updated Azure to allow defining ``authorization_url_params``
1011

1112
`2.2.0`_ (2019-06-04)
1213
---------------------

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
"flask": ("http://flask.pocoo.org/docs/", None),
282282
"flask_login": ("https://flask-login.readthedocs.io/en/latest/", None),
283283
"werkzeug": ("http://werkzeug.pocoo.org/docs/", None),
284-
"requests": ("https://requests.kennethreitz.org/en/latest/", None),
284+
"requests": ("http://docs.python-requests.org/en/latest/", None),
285285
"oauthlib": ("https://oauthlib.readthedocs.io/en/latest/", None),
286286
"requests_oauthlib": ("https://requests-oauthlib.readthedocs.io/en/latest/", None),
287287
"sqlalchemy": ("https://docs.sqlalchemy.org/en/latest/", None),

docs/testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,5 @@ Provided Pytest Fixture
201201

202202
.. _pytest: https://docs.pytest.org/
203203
.. _Betamax: https://github.com/betamaxpy/betamax
204-
.. _Requests: https://requests.kennethreitz.org/
204+
.. _Requests: http://docs.python-requests.org
205205
.. _@sigmavirus24: https://github.com/sigmavirus24/

flask_dance/contrib/azure.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def make_azure_blueprint(
2121
redirect_to=None,
2222
login_url=None,
2323
authorized_url=None,
24+
authorization_url_params=None,
2425
session_class=None,
2526
storage=None,
2627
tenant="common",
@@ -45,6 +46,10 @@ def make_azure_blueprint(
4546
Defaults to ``/azure``
4647
authorized_url (str, optional): the URL path for the ``authorized`` view.
4748
Defaults to ``/azure/authorized``.
49+
authorization_url_params (dict, optional): A dict of extra
50+
key-value pairs to include in the query string of the
51+
``authorization_url``, beyond those necessary for a standard
52+
OAuth 2 authorization grant request.
4853
session_class (class, optional): The class to use for creating a
4954
Requests session. Defaults to
5055
:class:`~flask_dance.consumer.requests.OAuth2Session`.
@@ -78,6 +83,7 @@ def make_azure_blueprint(
7883
redirect_to=redirect_to,
7984
login_url=login_url,
8085
authorized_url=authorized_url,
86+
authorization_url_params=authorization_url_params,
8187
session_class=session_class,
8288
storage=storage,
8389
)

tests/contrib/test_azure.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ def _make_app(*args, **kwargs):
2626

2727
def test_blueprint_factory():
2828
azure_bp = make_azure_blueprint(
29-
client_id="foo", client_secret="bar", scope="user.read", redirect_to="index"
29+
client_id="foo",
30+
client_secret="bar",
31+
scope="user.read",
32+
redirect_to="index",
33+
authorization_url_params={"prompt": "select_account"},
3034
)
3135
assert isinstance(azure_bp, OAuth2ConsumerBlueprint)
3236
assert azure_bp.session.scope == "user.read"
3337
assert azure_bp.session.base_url == "https://graph.microsoft.com"
3438
assert azure_bp.session.client_id == "foo"
3539
assert azure_bp.client_secret == "bar"
40+
assert azure_bp.authorization_url_params["prompt"] == "select_account"
3641
assert (
3742
azure_bp.authorization_url
3843
== "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
@@ -50,12 +55,14 @@ def test_blueprint_factory_with_organization_tenant():
5055
scope="user.read",
5156
redirect_to="index",
5257
tenant="organizations",
58+
authorization_url_params={"prompt": "select_account"},
5359
)
5460
assert isinstance(azure_orgs_bp, OAuth2ConsumerBlueprint)
5561
assert azure_orgs_bp.session.scope == "user.read"
5662
assert azure_orgs_bp.session.base_url == "https://graph.microsoft.com"
5763
assert azure_orgs_bp.session.client_id == "foo"
5864
assert azure_orgs_bp.client_secret == "bar"
65+
assert azure_orgs_bp.authorization_url_params["prompt"] == "select_account"
5966
assert (
6067
azure_orgs_bp.authorization_url
6168
== "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize"

0 commit comments

Comments
 (0)