my-cloud-devops-consulting 1.1.202507170113__py3-none-any.whl → 1.1.202507211454__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- app.py +53 -0
- {my_cloud_devops_consulting-1.1.202507170113.dist-info → my_cloud_devops_consulting-1.1.202507211454.dist-info}/METADATA +1 -1
- my_cloud_devops_consulting-1.1.202507211454.dist-info/RECORD +5 -0
- my_cloud_devops_consulting-1.1.202507170113.dist-info/RECORD +0 -5
- {my_cloud_devops_consulting-1.1.202507170113.dist-info → my_cloud_devops_consulting-1.1.202507211454.dist-info}/WHEEL +0 -0
- {my_cloud_devops_consulting-1.1.202507170113.dist-info → my_cloud_devops_consulting-1.1.202507211454.dist-info}/top_level.txt +0 -0
app.py
CHANGED
@@ -250,6 +250,59 @@ def reset_password(token):
|
|
250
250
|
def cookie_policy():
|
251
251
|
return render_template('cookie-policy.html')
|
252
252
|
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
# Cognito OIDC setup
|
257
|
+
# Add and configure the authlib OAuth component.
|
258
|
+
from flask import Flask, redirect, url_for, session
|
259
|
+
from authlib.integrations.flask_client import OAuth
|
260
|
+
import os
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
oauth = OAuth(app)
|
265
|
+
|
266
|
+
oauth.register(
|
267
|
+
name='oidc',
|
268
|
+
authority='https://cognito-idp.us-east-1.amazonaws.com/us-east-1_TZVykdVvG',
|
269
|
+
client_id='1lc7qso1g3lr9kqbr0nb0jktbs',
|
270
|
+
client_secret='1f1qa6rf66549cta1uqpamjpjqt06ne3agvlgou638e56kmt8dve',
|
271
|
+
server_metadata_url='https://cognito-idp.us-east-1.amazonaws.com/us-east-1_TZVykdVvG/.well-known/openid-configuration',
|
272
|
+
client_kwargs={'scope': 'phone openid email'}
|
273
|
+
)
|
274
|
+
################################################
|
275
|
+
|
276
|
+
# Configure a login route to direct to Amazon Cognito managed login for authentication with a redirect to an authorize route.
|
277
|
+
@app.route('/login/cognito')
|
278
|
+
def login_cognito():
|
279
|
+
session.pop('user', None)
|
280
|
+
redirect_uri = url_for('authorize', _external=True)
|
281
|
+
return oauth.oidc.authorize_redirect(
|
282
|
+
redirect_uri,
|
283
|
+
prompt='login' # 🔄 Forces re-authentication from Cognito
|
284
|
+
)
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
# The OAuth module collects the access token and retrieves user data from the Amazon Cognito userInfo endpoint. Configure an authorize route to handle the access token and user data after authentication.
|
290
|
+
@app.route('/authorize')
|
291
|
+
def authorize():
|
292
|
+
token = oauth.oidc.authorize_access_token()
|
293
|
+
user = token['userinfo']
|
294
|
+
session['user'] = user
|
295
|
+
return redirect(url_for('home')) # ✅ Fixed: 'home' matches your defined route
|
296
|
+
|
297
|
+
|
298
|
+
# Configure a logout route that erases user session data.
|
299
|
+
@app.route('/logout/cognito')
|
300
|
+
def logout_cognito(): # ✅ Renamed to avoid conflict
|
301
|
+
session.pop('user', None)
|
302
|
+
return redirect(url_for('home')) # 🔁 Also change to 'home' if 'index' doesn't exist
|
303
|
+
|
304
|
+
|
305
|
+
|
253
306
|
if __name__ == '__main__':
|
254
307
|
app.run(debug=True, host='0.0.0.0', port=50)
|
255
308
|
|
@@ -0,0 +1,5 @@
|
|
1
|
+
app.py,sha256=kf-nKabfd4hJPYQv2sijm56CXGwKtgoHHAsL47G3j68,10675
|
2
|
+
my_cloud_devops_consulting-1.1.202507211454.dist-info/METADATA,sha256=DM885VS0yW-Ik40_HgXwWs6o18LYiapas7dzCcp_Qrc,785
|
3
|
+
my_cloud_devops_consulting-1.1.202507211454.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
+
my_cloud_devops_consulting-1.1.202507211454.dist-info/top_level.txt,sha256=io9g7LCbfmTG1SFKgEOGXmCFB9uMP2H5lerm0HiHWQE,4
|
5
|
+
my_cloud_devops_consulting-1.1.202507211454.dist-info/RECORD,,
|
@@ -1,5 +0,0 @@
|
|
1
|
-
app.py,sha256=louT27AsKc_y2u88tG8VMnSp4UPbHKg6LmttWc19lqg,8908
|
2
|
-
my_cloud_devops_consulting-1.1.202507170113.dist-info/METADATA,sha256=PISb_sGjgncf8rb8jA7N2cxJPaZWpVI1V795hRzF6ow,785
|
3
|
-
my_cloud_devops_consulting-1.1.202507170113.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
-
my_cloud_devops_consulting-1.1.202507170113.dist-info/top_level.txt,sha256=io9g7LCbfmTG1SFKgEOGXmCFB9uMP2H5lerm0HiHWQE,4
|
5
|
-
my_cloud_devops_consulting-1.1.202507170113.dist-info/RECORD,,
|
File without changes
|