Flask-Login512 2.1.1__tar.gz

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.
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.4
2
+ Name: Flask-Login512
3
+ Version: 2.1.1
4
+ Summary: Flask extension for Login512 Post-Quantum Biometrics and Passkeys
5
+ Home-page: https://login512.com
6
+ Author: Login512 Team
7
+ License: Apache-2.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: Flask>=2.0
14
+ Requires-Dist: httpx>=0.25.0
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license
21
+ Dynamic: requires-dist
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ # Flask-Login512
26
+
27
+ Official Flask extension and `@login512_required` decorator for **Login512** Zero-Image Post-Quantum Biometrics and Passkeys.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install Flask-Login512
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ```python
38
+ from flask import Flask, jsonify, g
39
+ from flask_login512 import Login512, login512_required
40
+
41
+ app = Flask(__name__)
42
+ app.config["LOGIN512_SECRET_KEY"] = "l512_sk_your_key"
43
+ Login512(app)
44
+
45
+ @app.route("/api/profile")
46
+ @login512_required
47
+ def profile():
48
+ return jsonify({"user": g.login512_user})
49
+
50
+ if __name__ == "__main__":
51
+ app.run()
52
+ ```
53
+
@@ -0,0 +1,8 @@
1
+ README.md
2
+ setup.py
3
+ Flask_Login512.egg-info/PKG-INFO
4
+ Flask_Login512.egg-info/SOURCES.txt
5
+ Flask_Login512.egg-info/dependency_links.txt
6
+ Flask_Login512.egg-info/requires.txt
7
+ Flask_Login512.egg-info/top_level.txt
8
+ flask_login512/__init__.py
@@ -0,0 +1,2 @@
1
+ Flask>=2.0
2
+ httpx>=0.25.0
@@ -0,0 +1 @@
1
+ flask_login512
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.4
2
+ Name: Flask-Login512
3
+ Version: 2.1.1
4
+ Summary: Flask extension for Login512 Post-Quantum Biometrics and Passkeys
5
+ Home-page: https://login512.com
6
+ Author: Login512 Team
7
+ License: Apache-2.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: Flask>=2.0
14
+ Requires-Dist: httpx>=0.25.0
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license
21
+ Dynamic: requires-dist
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ # Flask-Login512
26
+
27
+ Official Flask extension and `@login512_required` decorator for **Login512** Zero-Image Post-Quantum Biometrics and Passkeys.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install Flask-Login512
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ```python
38
+ from flask import Flask, jsonify, g
39
+ from flask_login512 import Login512, login512_required
40
+
41
+ app = Flask(__name__)
42
+ app.config["LOGIN512_SECRET_KEY"] = "l512_sk_your_key"
43
+ Login512(app)
44
+
45
+ @app.route("/api/profile")
46
+ @login512_required
47
+ def profile():
48
+ return jsonify({"user": g.login512_user})
49
+
50
+ if __name__ == "__main__":
51
+ app.run()
52
+ ```
53
+
@@ -0,0 +1,29 @@
1
+ # Flask-Login512
2
+
3
+ Official Flask extension and `@login512_required` decorator for **Login512** Zero-Image Post-Quantum Biometrics and Passkeys.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install Flask-Login512
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from flask import Flask, jsonify, g
15
+ from flask_login512 import Login512, login512_required
16
+
17
+ app = Flask(__name__)
18
+ app.config["LOGIN512_SECRET_KEY"] = "l512_sk_your_key"
19
+ Login512(app)
20
+
21
+ @app.route("/api/profile")
22
+ @login512_required
23
+ def profile():
24
+ return jsonify({"user": g.login512_user})
25
+
26
+ if __name__ == "__main__":
27
+ app.run()
28
+ ```
29
+
@@ -0,0 +1,51 @@
1
+ from functools import wraps
2
+ from flask import request, jsonify, g, current_app
3
+ import httpx
4
+
5
+ class Login512:
6
+ def __init__(self, app=None):
7
+ if app is not None:
8
+ self.init_app(app)
9
+
10
+ def init_app(self, app):
11
+ app.config.setdefault("LOGIN512_ENDPOINT", "https://api.login512.com")
12
+
13
+ def login512_required(f):
14
+ @wraps(f)
15
+ def decorated_function(*args, **kwargs):
16
+ auth_header = request.headers.get("Authorization")
17
+ if not auth_header or not auth_header.startswith("Bearer "):
18
+ return jsonify({"error": "Missing or malformed Authorization header"}), 401
19
+
20
+ token = auth_header.split(" ", 1)[1]
21
+ secret_key = current_app.config.get("LOGIN512_SECRET_KEY")
22
+ endpoint = current_app.config.get("LOGIN512_ENDPOINT", "https://api.login512.com").rstrip("/")
23
+
24
+ if not secret_key:
25
+ return jsonify({"error": "LOGIN512_SECRET_KEY is not configured"}), 500
26
+
27
+ try:
28
+ with httpx.Client(timeout=8.0) as client:
29
+ res = client.post(
30
+ f"{endpoint}/v1/token/verify",
31
+ headers={"Authorization": f"Bearer {secret_key}"},
32
+ json={"token": token}
33
+ )
34
+ data = res.json()
35
+ if res.status_code != 200 or data.get("valid") is not True:
36
+ # The API sends "error" as a code string for rejected tokens (200 + valid:false) and as an
37
+ # object {"code","message"} for HTTP errors.
38
+ err = data.get("error")
39
+ if isinstance(err, dict):
40
+ err = err.get("message") or err.get("code")
41
+ return jsonify({"error": err or "Invalid token"}), 401
42
+ if data.get("step_up_required") is True:
43
+ return jsonify({"error": "STEP_UP_REQUIRED"}), 401
44
+
45
+ g.login512_user = data.get("claims")
46
+ except Exception as e:
47
+ return jsonify({"error": str(e)}), 401
48
+
49
+ return f(*args, **kwargs)
50
+ return decorated_function
51
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,21 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="Flask-Login512",
5
+ version="2.1.1",
6
+ packages=find_packages(),
7
+ install_requires=["Flask>=2.0", "httpx>=0.25.0"],
8
+ python_requires=">=3.9",
9
+ author="Login512 Team",
10
+ description="Flask extension for Login512 Post-Quantum Biometrics and Passkeys",
11
+ long_description=open("README.md", encoding="utf-8").read(),
12
+ long_description_content_type="text/markdown",
13
+ license="Apache-2.0",
14
+ url="https://login512.com",
15
+ classifiers=[
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Operating System :: OS Independent",
19
+ ],
20
+ )
21
+