skgen 1.0.0__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.
skgen-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Asinerum Conlang Project
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
skgen-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: skgen
3
+ Version: 1.0.0
4
+ Summary: Secret Setup Key Generating Web App
5
+ Home-page: https://github.com/asinerum/skgen
6
+ Author: Asinerum Conlang Project
7
+ Author-email: asinerum.com@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.7
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: python-dotenv>=1.2.1
16
+ Requires-Dist: python-multipart>=0.0.29
17
+ Requires-Dist: starlette>=0.50.0
18
+ Requires-Dist: uvicorn>=0.38.0
19
+ Requires-Dist: pavro>=1.0.2
20
+ Requires-Dist: tier2>=1.0.2
21
+ Requires-Dist: tagrepo
22
+ Dynamic: license-file
23
+
24
+ # Authenticator Secret Setup Key Generating Web Tool
25
+
26
+ Detailed tips, tricks, and examples, can be found at project's repository
27
+ https://github.com/asinerum/skgen
28
+
29
+ (C) 2026 Asinerum Conlang Project
skgen-1.0.0/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # Authenticator Secret Setup Key Generating Web Tool
2
+
3
+ Detailed tips, tricks, and examples, can be found at project's repository
4
+ https://github.com/asinerum/skgen
5
+
6
+ (C) 2026 Asinerum Conlang Project
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
skgen-1.0.0/setup.cfg ADDED
@@ -0,0 +1,36 @@
1
+ [metadata]
2
+ name = skgen
3
+ version = 1.0.0
4
+ author = Asinerum Conlang Project
5
+ author_email = asinerum.com@gmail.com
6
+ description = Secret Setup Key Generating Web App
7
+ long_description = file: README.md
8
+ long_description_content_type = text/markdown
9
+ url = https://github.com/asinerum/skgen
10
+ license = MIT
11
+ classifiers =
12
+ Programming Language :: Python :: 3
13
+ License :: OSI Approved :: MIT License
14
+ Operating System :: OS Independent
15
+
16
+ [options]
17
+ package_dir =
18
+ = src
19
+ packages = find:
20
+ python_requires = >=3.7
21
+ install_requires =
22
+ python-dotenv >= 1.2.1
23
+ python-multipart >= 0.0.29
24
+ starlette >= 0.50.0
25
+ uvicorn >= 0.38.0
26
+ pavro >= 1.0.2
27
+ tier2 >= 1.0.2
28
+ tagrepo
29
+
30
+ [options.packages.find]
31
+ where = src
32
+
33
+ [egg_info]
34
+ tag_build =
35
+ tag_date = 0
36
+
@@ -0,0 +1,3 @@
1
+ from .gen import *
2
+
3
+ __version__ = "1.0.0"
@@ -0,0 +1,105 @@
1
+ """
2
+ Google Authenticator Secret Setup Key Generating Web Tool
3
+ Dependencies: pip install [tagrepo] uvia vapp skgen
4
+ Usage: uvia -a vapp -m skgen [-p <PORT>]
5
+ """
6
+
7
+ import os
8
+ import uvicorn ## for <uvia>
9
+ from dotenv import load_dotenv
10
+ from starlette.responses import HTMLResponse
11
+ from starlette.requests import Request
12
+
13
+ from tagrepo import *
14
+ from pavro import select_avro_file, read_avro_file, avro_file_insert
15
+ from tier2 import create_google_random_setup_key, verify_google_code, generate_google_authenticator_qr
16
+
17
+ APP_PORT = 1937
18
+ APP_DESC = 'Authenticator Secret Setup Key Generating Web Tool'
19
+
20
+ load_dotenv()
21
+
22
+ FORM_TITLE = os.getenv('FORM_TITLE') or 'Authenticator Secret Setup Key Generator'
23
+ LABEL_INPUT_PARAMS = os.getenv('LABEL_INPUT_PARAMS') or 'Input issuer name and user email'
24
+ LABEL_SELECT_SHOW_KEY = os.getenv('LABEL_SELECT_SHOW_KEY') or 'Show secret key in output'
25
+ LABEL_SELECT_SAVE_KEY = os.getenv('LABEL_SELECT_SAVE_KEY') or 'Save secret key to database'
26
+ LABEL_ISSUER_NAME = os.getenv('LABEL_ISSUER_NAME') or 'Issuer name'
27
+ LABEL_USER_EMAIL = os.getenv('LABEL_USER_EMAIL') or 'User email'
28
+ LABEL_SUBMIT_BUTTON = os.getenv('LABEL_SUBMIT_BUTTON') or 'Generate'
29
+
30
+ STYLE_SUBMIT_BUTTON = os.getenv('STYLE_SUBMIT_BUTTON', APP_SUBMIT_BUTTON_STYLE)
31
+
32
+ KEY_ALREADY_EXISTS = os.getenv('KEY_ALREADY_EXISTS', 'Warning: secret key for this email already exists')
33
+ MISSING_INPUT_DATA = os.getenv('MISSING_INPUT_DATA', 'Error: missing input data')
34
+ SECRET_SETUP_KEY = os.getenv('SECRET_SETUP_KEY', 'Output: secret setup key')
35
+ SCAN_QR_WITH_APP = os.getenv('SCAN_QR_WITH_APP', 'Important: scan qr code with authenticator app')
36
+
37
+ FILE_AVRO_DATA =os.getenv('FILE_AVRO_DATA', './setupkeys.avro')
38
+
39
+ upper = lambda s: str(s).upper()
40
+ lower = lambda s: str(s).lower()
41
+
42
+ def check_setup_key_exist(email: str) -> int:
43
+ df = select_avro_file(FILE_AVRO_DATA, {"all": [{"==": ["email", lower(email), lower]}]})
44
+ return 0 if df is None else len(df)
45
+
46
+ def add_setup_key(name: str, email: str, key: str) -> bool:
47
+ return avro_file_insert(FILE_AVRO_DATA, name=str(name), email=lower(email), key=str(key))
48
+
49
+ def html_input_params():
50
+ return f'''
51
+ {html_input_texts(["name", "email"], [LABEL_ISSUER_NAME, LABEL_USER_EMAIL])}
52
+ {html_checkbox(LABEL_SELECT_SHOW_KEY, "showkey")}
53
+ {html_checkbox(LABEL_SELECT_SAVE_KEY, "savekey")}
54
+ '''
55
+
56
+ def form_page():
57
+ return f'''
58
+ <!DOCTYPE html>
59
+ {APP_CHARSET}
60
+ {APP_VIEWPORT}
61
+ <html><body>
62
+ <p><h2>{FORM_TITLE}</h2></p>
63
+ <form method="post">
64
+ <p>{html_fieldset(LABEL_INPUT_PARAMS, html_input_params())}</p>
65
+ <p><button style="{STYLE_SUBMIT_BUTTON}" type="submit">{LABEL_SUBMIT_BUTTON}</button></p>
66
+ </form>
67
+ </body></html>
68
+ '''
69
+
70
+ def homepage(formpage=form_page):
71
+ async def submit(request: Request):
72
+ if request.method == 'GET':
73
+ return HTMLResponse(formpage())
74
+ else:
75
+ form = await request.form()
76
+ name = form['name']
77
+ email = form['email']
78
+ showkey = form.get('showkey')
79
+ savekey = form.get('savekey')
80
+ return HTMLResponse(result_page(name=name, email=email, showkey=showkey, savekey=savekey, body_func=html_body))
81
+ return submit
82
+
83
+ def result_page(name: str, email: str, showkey: bool, savekey: bool, body_func):
84
+ return f'''
85
+ <!DOCTYPE html>
86
+ {APP_CHARSET}
87
+ {APP_VIEWPORT}
88
+ <html><body>
89
+ <p><h2>{FORM_TITLE}</h2></p>
90
+ {body_func(name, email, showkey, savekey)}
91
+ </body></html>
92
+ '''
93
+
94
+ def html_body(name: str, email: str, showkey: bool, savekey: bool) -> str:
95
+ name = name.strip()
96
+ email = email.strip().lower()
97
+ if not name or not email: return f'<p>{MISSING_INPUT_DATA}</p>'
98
+ if savekey and check_setup_key_exist(email): return f'<p>{KEY_ALREADY_EXISTS}</p>'
99
+ key = create_google_random_setup_key()
100
+ if savekey: avro_file_insert(FILE_AVRO_DATA, name=name, email=email, key=key)
101
+ qrdat = generate_google_authenticator_qr(key, name, email, None)
102
+ html = f'<p>{name}<br/>{email}</p>'
103
+ html += f'<p>{SECRET_SETUP_KEY}</p><p><h3>{key}</h3></p>' if showkey else f'<p>{SCAN_QR_WITH_APP}</p>'
104
+ html += f'<p><img src="{qrdat}"/></p>'
105
+ return html
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: skgen
3
+ Version: 1.0.0
4
+ Summary: Secret Setup Key Generating Web App
5
+ Home-page: https://github.com/asinerum/skgen
6
+ Author: Asinerum Conlang Project
7
+ Author-email: asinerum.com@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.7
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: python-dotenv>=1.2.1
16
+ Requires-Dist: python-multipart>=0.0.29
17
+ Requires-Dist: starlette>=0.50.0
18
+ Requires-Dist: uvicorn>=0.38.0
19
+ Requires-Dist: pavro>=1.0.2
20
+ Requires-Dist: tier2>=1.0.2
21
+ Requires-Dist: tagrepo
22
+ Dynamic: license-file
23
+
24
+ # Authenticator Secret Setup Key Generating Web Tool
25
+
26
+ Detailed tips, tricks, and examples, can be found at project's repository
27
+ https://github.com/asinerum/skgen
28
+
29
+ (C) 2026 Asinerum Conlang Project
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.cfg
5
+ src/skgen/__init__.py
6
+ src/skgen/gen.py
7
+ src/skgen.egg-info/PKG-INFO
8
+ src/skgen.egg-info/SOURCES.txt
9
+ src/skgen.egg-info/dependency_links.txt
10
+ src/skgen.egg-info/requires.txt
11
+ src/skgen.egg-info/top_level.txt
@@ -0,0 +1,7 @@
1
+ python-dotenv>=1.2.1
2
+ python-multipart>=0.0.29
3
+ starlette>=0.50.0
4
+ uvicorn>=0.38.0
5
+ pavro>=1.0.2
6
+ tier2>=1.0.2
7
+ tagrepo
@@ -0,0 +1 @@
1
+ skgen