Skip to content

Commit 1c7e213

Browse files
update version and readme
1 parent 289405f commit 1c7e213

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.4.0
2+
- Add `MAuthWSGIMiddleware` for authenticating requests in WSGI frameworks like Flask.
3+
- Remove `FlaskAuthenticator`.
4+
15
# 1.3.0
26
- Add `MAuthASGIMiddleware` for authenticating requests in ASGI frameworks like FastAPI.
37
- Remove Support for EOL Python 3.6

README.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,30 +112,37 @@ authentic, status_code, message = authenticator.is_authentic()
112112
app_uuid = authenticator.get_app_uuid()
113113
```
114114

115-
#### Flask applications
115+
#### WSGI Applications
116116

117-
You will need to create an application instance and initialize it with `FlaskAuthenticator`.
118-
To specify routes that need to be authenticated use the `requires_authentication` decorator.
117+
To apply to a WSGI application you should use the `MAuthWSGIMiddleware`. You
118+
can make certain paths exempt from authentication by passing the `exempt`
119+
option with a set of paths to exempt.
120+
121+
Here is an example for Flask. Note that requesting app's UUID and the
122+
protocol version will be added to the request environment for successfully
123+
authenticated requests.
119124

120125
```python
121-
from flask import Flask
122-
from mauth_client.flask_authenticator import FlaskAuthenticator, requires_authentication
126+
from flask import Flask, request, jsonify
127+
from mauth_client.consts import ENV_APP_UUID, ENV_PROTOCOL_VERSION
128+
from mauth_client.middlewares import MAuthWSGIMiddleware
123129

124-
app = Flask("Some Sample App")
125-
authenticator = FlaskAuthenticator()
126-
authenticator.init_app(app)
130+
app = Flask("MyApp")
131+
app.wsgi_app = MAuthWSGIMiddleware(app.wsgi_app, exempt={"/app_status"})
127132

128-
@app.route("/some/private/route", methods=["GET"])
129-
@requires_authentication
130-
def private_route():
131-
return "Wibble"
133+
@app.get("/")
134+
def root():
135+
return jsonify({
136+
"msg": "authenticated",
137+
"app_uuid": request.environ[ENV_APP_UUID],
138+
"protocol_version": request.environ[ENV_PROTOCOL_VERSION],
139+
})
132140

133-
@app.route("/app_status", methods=["GET"])
134-
def app_status():
135-
return "OK"
141+
@app.get("/app_status")
142+
return "this route is exempt from authentication"
136143
```
137144

138-
#### ASGI applications
145+
#### ASGI Applications
139146

140147
To apply to an ASGI application you should use the `MAuthASGIMiddleware`. You
141148
can make certain paths exempt from authentication by passing the `exempt`

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mauth-client"
3-
version = "1.3.0"
3+
version = "1.4.0"
44
description = "MAuth Client for Python"
55
repository = "https://github.com/mdsol/mauth-client-python"
66
authors = ["Medidata Solutions <[email protected]>"]
@@ -13,10 +13,10 @@ classifiers = [
1313
"License :: OSI Approved :: MIT License",
1414
"Operating System :: OS Independent",
1515
"Programming Language :: Python",
16-
"Programming Language :: Python :: 3.6",
1716
"Programming Language :: Python :: 3.7",
1817
"Programming Language :: Python :: 3.8",
1918
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
2020
"Topic :: Internet :: WWW/HTTP",
2121
"Topic :: Software Development :: Libraries :: Python Modules",
2222
]

0 commit comments

Comments
 (0)