cmdbox 0.5.0.8__py3-none-any.whl → 0.5.1__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.
Potentially problematic release.
This version of cmdbox might be problematic. Click here for more details.
- cmdbox/app/edge.py +96 -12
- cmdbox/app/features/cli/cmdbox_edge_config.py +9 -3
- cmdbox/app/features/cli/cmdbox_gui_start.py +1 -1
- cmdbox/app/features/cli/cmdbox_web_start.py +2 -1
- cmdbox/app/features/web/cmdbox_web_bbforce_cmd.py +1 -1
- cmdbox/app/features/web/cmdbox_web_copyright.py +1 -1
- cmdbox/app/features/web/cmdbox_web_del_cmd.py +1 -1
- cmdbox/app/features/web/cmdbox_web_del_pipe.py +1 -1
- cmdbox/app/features/web/cmdbox_web_do_signin.py +88 -32
- cmdbox/app/features/web/cmdbox_web_exec_cmd.py +2 -2
- cmdbox/app/features/web/cmdbox_web_exec_pipe.py +2 -2
- cmdbox/app/features/web/cmdbox_web_filer download.py +2 -3
- cmdbox/app/features/web/cmdbox_web_filer.py +1 -1
- cmdbox/app/features/web/cmdbox_web_filer_upload.py +1 -1
- cmdbox/app/features/web/cmdbox_web_get_cmd_choices.py +1 -1
- cmdbox/app/features/web/cmdbox_web_get_cmds.py +2 -2
- cmdbox/app/features/web/cmdbox_web_get_modes.py +2 -2
- cmdbox/app/features/web/cmdbox_web_get_server_opt.py +1 -1
- cmdbox/app/features/web/cmdbox_web_gui.py +2 -2
- cmdbox/app/features/web/cmdbox_web_list_cmd.py +2 -2
- cmdbox/app/features/web/cmdbox_web_list_pipe.py +2 -2
- cmdbox/app/features/web/cmdbox_web_load_cmd.py +1 -1
- cmdbox/app/features/web/cmdbox_web_load_pin.py +3 -5
- cmdbox/app/features/web/cmdbox_web_load_pipe.py +1 -1
- cmdbox/app/features/web/cmdbox_web_raw_cmd.py +1 -1
- cmdbox/app/features/web/cmdbox_web_raw_pipe.py +1 -1
- cmdbox/app/features/web/cmdbox_web_result.py +2 -2
- cmdbox/app/features/web/cmdbox_web_save_cmd.py +1 -1
- cmdbox/app/features/web/cmdbox_web_save_pin.py +2 -2
- cmdbox/app/features/web/cmdbox_web_save_pipe.py +1 -1
- cmdbox/app/features/web/cmdbox_web_signin.py +26 -8
- cmdbox/app/features/web/cmdbox_web_users.py +35 -37
- cmdbox/app/features/web/cmdbox_web_versions_cmdbox.py +1 -1
- cmdbox/app/features/web/cmdbox_web_versions_used.py +1 -1
- cmdbox/app/options.py +8 -8
- cmdbox/app/web.py +76 -555
- cmdbox/extensions/sample_project/sample/extensions/features.yml +38 -13
- cmdbox/extensions/sample_project/sample/extensions/user_list.yml +82 -40
- cmdbox/extensions/user_list.yml +10 -0
- cmdbox/version.py +2 -2
- cmdbox/web/assets/cmdbox/list_cmd.js +50 -2
- cmdbox/web/assets/cmdbox/signin.js +7 -0
- cmdbox/web/gui.html +1 -0
- cmdbox/web/signin.html +7 -0
- {cmdbox-0.5.0.8.dist-info → cmdbox-0.5.1.dist-info}/METADATA +1 -1
- {cmdbox-0.5.0.8.dist-info → cmdbox-0.5.1.dist-info}/RECORD +50 -51
- cmdbox/app/signin.py +0 -56
- {cmdbox-0.5.0.8.dist-info → cmdbox-0.5.1.dist-info}/LICENSE +0 -0
- {cmdbox-0.5.0.8.dist-info → cmdbox-0.5.1.dist-info}/WHEEL +0 -0
- {cmdbox-0.5.0.8.dist-info → cmdbox-0.5.1.dist-info}/entry_points.txt +0 -0
- {cmdbox-0.5.0.8.dist-info → cmdbox-0.5.1.dist-info}/top_level.txt +0 -0
|
@@ -19,7 +19,7 @@ class FilerUpload(cmdbox_web_exec_cmd.ExecCmd):
|
|
|
19
19
|
"""
|
|
20
20
|
@app.post('/filer/upload', response_class=PlainTextResponse)
|
|
21
21
|
async def filer_upload(req:Request, res:Response):
|
|
22
|
-
signin = web.check_signin(req, res)
|
|
22
|
+
signin = web.signin.check_signin(req, res)
|
|
23
23
|
if signin is not None:
|
|
24
24
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
25
25
|
return await self.filer_upload(web, req, res)
|
|
@@ -14,7 +14,7 @@ class GetCmdChoices(feature.WebFeature):
|
|
|
14
14
|
"""
|
|
15
15
|
@app.post('/gui/get_cmd_choices')
|
|
16
16
|
async def get_cmd_choices(req:Request, res:Response):
|
|
17
|
-
signin = web.check_signin(req, res)
|
|
17
|
+
signin = web.signin.check_signin(req, res)
|
|
18
18
|
if signin is not None:
|
|
19
19
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
20
20
|
form = await req.form()
|
|
@@ -16,11 +16,11 @@ class GetCmds(feature.WebFeature):
|
|
|
16
16
|
"""
|
|
17
17
|
@app.post('/gui/get_cmds', response_class=PlainTextResponse)
|
|
18
18
|
async def get_cmds(req:Request, res:Response):
|
|
19
|
-
signin = web.check_signin(req, res)
|
|
19
|
+
signin = web.signin.check_signin(req, res)
|
|
20
20
|
if signin is not None:
|
|
21
21
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
22
22
|
form = await req.form()
|
|
23
23
|
mode = form.get('mode')
|
|
24
24
|
#ret = web.options.get_cmds(mode)
|
|
25
|
-
ret = web.get_enable_cmds(mode, req, res)
|
|
25
|
+
ret = web.signin.get_enable_cmds(mode, req, res)
|
|
26
26
|
return json.dumps(ret, default=common.default_json_enc)
|
|
@@ -16,9 +16,9 @@ class GetModes(feature.WebFeature):
|
|
|
16
16
|
"""
|
|
17
17
|
@app.get('/gui/get_modes', response_class=PlainTextResponse)
|
|
18
18
|
async def get_modes(req:Request, res:Response):
|
|
19
|
-
signin = web.check_signin(req, res)
|
|
19
|
+
signin = web.signin.check_signin(req, res)
|
|
20
20
|
if signin is not None:
|
|
21
21
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
22
|
-
ret = web.get_enable_modes(req, res)
|
|
22
|
+
ret = web.signin.get_enable_modes(req, res)
|
|
23
23
|
return json.dumps(ret, default=common.default_json_enc)
|
|
24
24
|
|
|
@@ -15,7 +15,7 @@ class GetServerOpt(feature.WebFeature):
|
|
|
15
15
|
"""
|
|
16
16
|
@app.get('/get_server_opt')
|
|
17
17
|
async def get_server_opt(req:Request, res:Response):
|
|
18
|
-
signin = web.check_signin(req, res)
|
|
18
|
+
signin = web.signin.check_signin(req, res)
|
|
19
19
|
if signin is not None:
|
|
20
20
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
21
21
|
opt = dict(host=web.redis_host, port=web.redis_port, password=web.redis_password, svname=web.svname,
|
|
@@ -35,7 +35,7 @@ class Gui(feature.WebFeature):
|
|
|
35
35
|
@app.get('/gui', response_class=HTMLResponse)
|
|
36
36
|
@app.post('/gui', response_class=HTMLResponse)
|
|
37
37
|
async def gui(req:Request, res:Response):
|
|
38
|
-
signin = web.check_signin(req, res)
|
|
38
|
+
signin = web.signin.check_signin(req, res)
|
|
39
39
|
if signin is not None:
|
|
40
40
|
return signin
|
|
41
41
|
res.headers['Access-Control-Allow-Origin'] = '*'
|
|
@@ -73,7 +73,7 @@ class Gui(feature.WebFeature):
|
|
|
73
73
|
async def toolmenu(req:Request, res:Response):
|
|
74
74
|
ret = dict()
|
|
75
75
|
for k, v in web.toolmenu.items():
|
|
76
|
-
path_jadge = web.check_path(req, v['href'])
|
|
76
|
+
path_jadge = web.signin.check_path(req, v['href'])
|
|
77
77
|
if path_jadge is not None:
|
|
78
78
|
continue
|
|
79
79
|
ret[k] = v
|
|
@@ -17,13 +17,13 @@ class ListCmd(feature.WebFeature):
|
|
|
17
17
|
"""
|
|
18
18
|
@app.post('/gui/list_cmd')
|
|
19
19
|
async def list_cmd(req:Request, res:Response):
|
|
20
|
-
signin = web.check_signin(req, res)
|
|
20
|
+
signin = web.signin.check_signin(req, res)
|
|
21
21
|
if signin is not None:
|
|
22
22
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
23
23
|
form = await req.form()
|
|
24
24
|
kwd = form.get('kwd')
|
|
25
25
|
ret = self.list_cmd(web, kwd)
|
|
26
|
-
ret = [r for r in ret if web.check_cmd(req, res, r['mode'], r['cmd'])]
|
|
26
|
+
ret = [r for r in ret if web.signin.check_cmd(req, res, r['mode'], r['cmd'])]
|
|
27
27
|
return ret
|
|
28
28
|
|
|
29
29
|
def list_cmd(self, web:Web, kwd:str) -> List[Dict[str, Any]]:
|
|
@@ -17,7 +17,7 @@ class ListPipe(feature.WebFeature):
|
|
|
17
17
|
"""
|
|
18
18
|
@app.post('/gui/list_pipe')
|
|
19
19
|
async def list_pipe(req:Request, res:Response):
|
|
20
|
-
signin = web.check_signin(req, res)
|
|
20
|
+
signin = web.signin.check_signin(req, res)
|
|
21
21
|
if signin is not None:
|
|
22
22
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
23
23
|
form = await req.form()
|
|
@@ -57,4 +57,4 @@ class ListPipe(feature.WebFeature):
|
|
|
57
57
|
opt = common.loadopt(web.cmds_path / f'cmd-{title}.json', True)
|
|
58
58
|
if 'mode' not in opt or 'cmd' not in opt:
|
|
59
59
|
return False
|
|
60
|
-
return web.check_cmd(req, res, opt['mode'], opt['cmd'])
|
|
60
|
+
return web.signin.check_cmd(req, res, opt['mode'], opt['cmd'])
|
|
@@ -17,7 +17,7 @@ class LoadCmd(cmdbox_web_gui.Gui):
|
|
|
17
17
|
"""
|
|
18
18
|
@app.post('/gui/load_cmd')
|
|
19
19
|
async def load_cmd(req:Request, res:Response):
|
|
20
|
-
signin = web.check_signin(req, res)
|
|
20
|
+
signin = web.signin.check_signin(req, res)
|
|
21
21
|
if signin is not None:
|
|
22
22
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
23
23
|
form = await req.form()
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
from cmdbox.app import
|
|
1
|
+
from cmdbox.app import feature
|
|
2
2
|
from cmdbox.app.web import Web
|
|
3
3
|
from fastapi import FastAPI, Request, Response, HTTPException
|
|
4
|
-
from typing import Dict, Any
|
|
5
|
-
import json
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
class LoadPin(feature.WebFeature):
|
|
@@ -16,7 +14,7 @@ class LoadPin(feature.WebFeature):
|
|
|
16
14
|
"""
|
|
17
15
|
@app.post('/gui/load_cmd_pin')
|
|
18
16
|
async def load_cmd_pin(req:Request, res:Response):
|
|
19
|
-
signin = web.check_signin(req, res)
|
|
17
|
+
signin = web.signin.check_signin(req, res)
|
|
20
18
|
if signin is not None:
|
|
21
19
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
22
20
|
if 'signin' not in req.session or req.session['signin'] is None:
|
|
@@ -31,7 +29,7 @@ class LoadPin(feature.WebFeature):
|
|
|
31
29
|
|
|
32
30
|
@app.post('/gui/load_pipe_pin')
|
|
33
31
|
async def load_pipe_pin(req:Request, res:Response):
|
|
34
|
-
signin = web.check_signin(req, res)
|
|
32
|
+
signin = web.signin.check_signin(req, res)
|
|
35
33
|
if signin is not None:
|
|
36
34
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
37
35
|
if 'signin' not in req.session or req.session['signin'] is None:
|
|
@@ -17,7 +17,7 @@ class LoadPipe(feature.WebFeature):
|
|
|
17
17
|
"""
|
|
18
18
|
@app.post('/gui/load_pipe')
|
|
19
19
|
async def load_pipe(req:Request, res:Response):
|
|
20
|
-
signin = web.check_signin(req, res)
|
|
20
|
+
signin = web.signin.check_signin(req, res)
|
|
21
21
|
if signin is not None:
|
|
22
22
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
23
23
|
form = await req.form()
|
|
@@ -18,7 +18,7 @@ class RawCmd(cmdbox_web_gui.Gui):
|
|
|
18
18
|
"""
|
|
19
19
|
@app.post('/gui/raw_cmd')
|
|
20
20
|
async def raw_cmd(req:Request, res:Response):
|
|
21
|
-
signin = web.check_signin(req, res)
|
|
21
|
+
signin = web.signin.check_signin(req, res)
|
|
22
22
|
if signin is not None:
|
|
23
23
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
24
24
|
form = await req.form()
|
|
@@ -18,7 +18,7 @@ class RawPipe(cmdbox_web_raw_cmd.RawCmd, cmdbox_web_load_cmd.LoadCmd):
|
|
|
18
18
|
"""
|
|
19
19
|
@app.post('/gui/raw_pipe')
|
|
20
20
|
async def raw_pipe(req:Request, res:Response):
|
|
21
|
-
signin = web.check_signin(req, res)
|
|
21
|
+
signin = web.signin.check_signin(req, res)
|
|
22
22
|
if signin is not None:
|
|
23
23
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
24
24
|
form = await req.form()
|
|
@@ -23,7 +23,7 @@ class Result(feature.WebFeature):
|
|
|
23
23
|
|
|
24
24
|
@app.post('/result/pub')
|
|
25
25
|
async def result(req:Request, res:Response):
|
|
26
|
-
signin = web.check_signin(req, res)
|
|
26
|
+
signin = web.signin.check_signin(req, res)
|
|
27
27
|
if signin is not None:
|
|
28
28
|
return signin
|
|
29
29
|
form = await req.form()
|
|
@@ -39,7 +39,7 @@ class Result(feature.WebFeature):
|
|
|
39
39
|
@app.post('/result', response_class=HTMLResponse)
|
|
40
40
|
@app.get('/result', response_class=HTMLResponse)
|
|
41
41
|
async def result_html(req:Request, res:Response):
|
|
42
|
-
signin = web.check_signin(req, res)
|
|
42
|
+
signin = web.signin.check_signin(req, res)
|
|
43
43
|
if signin is not None:
|
|
44
44
|
return signin
|
|
45
45
|
res.headers['Access-Control-Allow-Origin'] = '*'
|
|
@@ -16,7 +16,7 @@ class SaveCmd(feature.WebFeature):
|
|
|
16
16
|
"""
|
|
17
17
|
@app.post('/gui/save_cmd')
|
|
18
18
|
async def save_cmd(req:Request, res:Response):
|
|
19
|
-
signin = web.check_signin(req, res)
|
|
19
|
+
signin = web.signin.check_signin(req, res)
|
|
20
20
|
if signin is not None:
|
|
21
21
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
22
22
|
form = await req.form()
|
|
@@ -15,7 +15,7 @@ class SavePin(feature.WebFeature):
|
|
|
15
15
|
"""
|
|
16
16
|
@app.post('/gui/save_cmd_pin')
|
|
17
17
|
async def save_cmd_pin(req:Request, res:Response):
|
|
18
|
-
signin = web.check_signin(req, res)
|
|
18
|
+
signin = web.signin.check_signin(req, res)
|
|
19
19
|
if signin is not None:
|
|
20
20
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
21
21
|
if 'signin' not in req.session or req.session['signin'] is None:
|
|
@@ -29,7 +29,7 @@ class SavePin(feature.WebFeature):
|
|
|
29
29
|
|
|
30
30
|
@app.post('/gui/save_pipe_pin')
|
|
31
31
|
async def save_pipe_pin(req:Request, res:Response):
|
|
32
|
-
signin = web.check_signin(req, res)
|
|
32
|
+
signin = web.signin.check_signin(req, res)
|
|
33
33
|
if signin is not None:
|
|
34
34
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
35
35
|
if 'signin' not in req.session or req.session['signin'] is None:
|
|
@@ -16,7 +16,7 @@ class SavePipe(feature.WebFeature):
|
|
|
16
16
|
"""
|
|
17
17
|
@app.post('/gui/save_pipe')
|
|
18
18
|
async def save_pipe(req:Request, res:Response):
|
|
19
|
-
signin = web.check_signin(req, res)
|
|
19
|
+
signin = web.signin.check_signin(req, res)
|
|
20
20
|
if signin is not None:
|
|
21
21
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
22
22
|
form = await req.form()
|
|
@@ -15,7 +15,7 @@ class Signin(feature.WebFeature):
|
|
|
15
15
|
web (Web): Webオブジェクト
|
|
16
16
|
app (FastAPI): FastAPIオブジェクト
|
|
17
17
|
"""
|
|
18
|
-
web.load_signin_file()
|
|
18
|
+
web.signin.signin_file_data = web.signin.load_signin_file(web.signin_file, web.signin.get_data())
|
|
19
19
|
if web.signin_html is not None:
|
|
20
20
|
if not web.signin_html.is_file():
|
|
21
21
|
raise HTTPException(status_code=500, detail=f'signin_html is not found. ({web.signin_html})')
|
|
@@ -24,8 +24,8 @@ class Signin(feature.WebFeature):
|
|
|
24
24
|
|
|
25
25
|
@app.get('/signin/{next}', response_class=HTMLResponse)
|
|
26
26
|
@app.post('/signin/{next}', response_class=HTMLResponse)
|
|
27
|
-
async def
|
|
28
|
-
web.enable_cors(req, res)
|
|
27
|
+
async def _signin(next:str, req:Request, res:Response):
|
|
28
|
+
web.signin.enable_cors(req, res)
|
|
29
29
|
res.headers['Access-Control-Allow-Origin'] = '*'
|
|
30
30
|
return web.signin_html_data
|
|
31
31
|
|
|
@@ -34,7 +34,7 @@ class Signin(feature.WebFeature):
|
|
|
34
34
|
async def oauth2_google(next:str, req:Request, res:Response):
|
|
35
35
|
if web.signin_html_data is None:
|
|
36
36
|
return RedirectResponse(url=f'../../{next}') # nginxのリバプロ対応のための相対パス
|
|
37
|
-
conf = web.
|
|
37
|
+
conf = web.signin.get_data()['oauth2']['providers']['google']
|
|
38
38
|
data = {'scope': ' '.join(conf['scope']),
|
|
39
39
|
'access_type': 'offline',
|
|
40
40
|
'response_type': 'code',
|
|
@@ -49,7 +49,7 @@ class Signin(feature.WebFeature):
|
|
|
49
49
|
async def oauth2_github(next:str, req:Request, res:Response):
|
|
50
50
|
if web.signin_html_data is None:
|
|
51
51
|
return RedirectResponse(url=f'../../{next}') # nginxのリバプロ対応のための相対パス
|
|
52
|
-
conf = web.
|
|
52
|
+
conf = web.signin.get_data()['oauth2']['providers']['github']
|
|
53
53
|
data = {'scope': ' '.join(conf['scope']),
|
|
54
54
|
'access_type': 'offline',
|
|
55
55
|
'response_type': 'code',
|
|
@@ -59,9 +59,27 @@ class Signin(feature.WebFeature):
|
|
|
59
59
|
query = '&'.join([f'{k}={urllib.parse.quote(v)}' for k, v in data.items()])
|
|
60
60
|
return RedirectResponse(url=f'https://github.com/login/oauth/authorize?{query}')
|
|
61
61
|
|
|
62
|
+
# https://learn.microsoft.com/ja-jp/entra/identity-platform/v2-oauth2-auth-code-flow
|
|
63
|
+
@app.get('/oauth2/azure/{next}')
|
|
64
|
+
async def oauth2_azure(next:str, req:Request, res:Response):
|
|
65
|
+
if web.signin_html_data is None:
|
|
66
|
+
return RedirectResponse(url=f'../../{next}') # nginxのリバプロ対応のための相対パス
|
|
67
|
+
conf = web.signin.get_data()['oauth2']['providers']['azure']
|
|
68
|
+
data = {'scope': ' '.join(conf['scope']),
|
|
69
|
+
'access_type': 'offline',
|
|
70
|
+
'response_type': 'code',
|
|
71
|
+
'redirect_uri': conf['redirect_uri'],
|
|
72
|
+
'client_id': conf['client_id'],
|
|
73
|
+
'response_mode': 'query',
|
|
74
|
+
'state': next}
|
|
75
|
+
query = '&'.join([f'{k}={urllib.parse.quote(v)}' for k, v in data.items()])
|
|
76
|
+
return RedirectResponse(url=f'https://login.microsoftonline.com/{conf["tenant_id"]}/oauth2/v2.0/authorize?{query}')
|
|
77
|
+
|
|
62
78
|
@app.get('/oauth2/enabled')
|
|
63
79
|
async def oauth2_enabled(req:Request, res:Response):
|
|
64
80
|
if web.signin_html_data is None:
|
|
65
|
-
return dict(google=False, github=False)
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
return dict(google=False, github=False, azure=False)
|
|
82
|
+
signin_data = web.signin.get_data()
|
|
83
|
+
return dict(google=signin_data['oauth2']['providers']['google']['enabled'],
|
|
84
|
+
github=signin_data['oauth2']['providers']['github']['enabled'],
|
|
85
|
+
azure=signin_data['oauth2']['providers']['azure']['enabled'],)
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
from cmdbox import
|
|
2
|
-
from cmdbox.app import common, feature
|
|
1
|
+
from cmdbox.app import feature
|
|
3
2
|
from cmdbox.app.web import Web
|
|
4
|
-
from fastapi import FastAPI, Request, Response
|
|
5
|
-
from fastapi.responses import HTMLResponse
|
|
3
|
+
from fastapi import FastAPI, Request, Response
|
|
4
|
+
from fastapi.responses import HTMLResponse
|
|
6
5
|
from typing import Dict, Any
|
|
7
|
-
import logging
|
|
8
6
|
|
|
9
7
|
|
|
10
8
|
class Users(feature.WebFeature):
|
|
@@ -26,7 +24,7 @@ class Users(feature.WebFeature):
|
|
|
26
24
|
@app.get('/users', response_class=HTMLResponse)
|
|
27
25
|
@app.post('/users', response_class=HTMLResponse)
|
|
28
26
|
async def users(req:Request, res:Response):
|
|
29
|
-
signin = web.check_signin(req, res)
|
|
27
|
+
signin = web.signin.check_signin(req, res)
|
|
30
28
|
if signin is not None:
|
|
31
29
|
return signin
|
|
32
30
|
res.headers['Access-Control-Allow-Origin'] = '*'
|
|
@@ -34,19 +32,19 @@ class Users(feature.WebFeature):
|
|
|
34
32
|
|
|
35
33
|
@app.get('/users/list')
|
|
36
34
|
async def users_list(req:Request, res:Response):
|
|
37
|
-
signin = web.check_signin(req, res)
|
|
35
|
+
signin = web.signin.check_signin(req, res)
|
|
38
36
|
if signin is not None:
|
|
39
37
|
return signin
|
|
40
|
-
if web.
|
|
38
|
+
if web.signin.get_data() is None:
|
|
41
39
|
return dict(error='signin_file_data is None.')
|
|
42
40
|
return web.user_list(None)
|
|
43
41
|
|
|
44
42
|
@app.post('/users/add')
|
|
45
43
|
async def users_add(req:Request, res:Response):
|
|
46
|
-
signin = web.check_signin(req, res)
|
|
44
|
+
signin = web.signin.check_signin(req, res)
|
|
47
45
|
if signin is not None:
|
|
48
46
|
return signin
|
|
49
|
-
if web.
|
|
47
|
+
if web.signin.get_data() is None:
|
|
50
48
|
return dict(error='signin_file_data is None.')
|
|
51
49
|
form = await req.json()
|
|
52
50
|
try:
|
|
@@ -57,10 +55,10 @@ class Users(feature.WebFeature):
|
|
|
57
55
|
|
|
58
56
|
@app.post('/users/edit')
|
|
59
57
|
async def users_edit(req:Request, res:Response):
|
|
60
|
-
signin = web.check_signin(req, res)
|
|
58
|
+
signin = web.signin.check_signin(req, res)
|
|
61
59
|
if signin is not None:
|
|
62
60
|
return signin
|
|
63
|
-
if web.
|
|
61
|
+
if web.signin.get_data() is None:
|
|
64
62
|
return dict(error='signin_file_data is None.')
|
|
65
63
|
form = await req.json()
|
|
66
64
|
try:
|
|
@@ -71,10 +69,10 @@ class Users(feature.WebFeature):
|
|
|
71
69
|
|
|
72
70
|
@app.post('/users/del')
|
|
73
71
|
async def users_del(req:Request, res:Response):
|
|
74
|
-
signin = web.check_signin(req, res)
|
|
72
|
+
signin = web.signin.check_signin(req, res)
|
|
75
73
|
if signin is not None:
|
|
76
74
|
return signin
|
|
77
|
-
if web.
|
|
75
|
+
if web.signin.get_data() is None:
|
|
78
76
|
return dict(error='signin_file_data is None.')
|
|
79
77
|
form = await req.json()
|
|
80
78
|
try:
|
|
@@ -87,10 +85,10 @@ class Users(feature.WebFeature):
|
|
|
87
85
|
|
|
88
86
|
@app.post('/users/apikey/add')
|
|
89
87
|
async def users_apikey_add(req:Request, res:Response):
|
|
90
|
-
signin = web.check_signin(req, res)
|
|
88
|
+
signin = web.signin.check_signin(req, res)
|
|
91
89
|
if signin is not None:
|
|
92
90
|
return signin
|
|
93
|
-
if web.
|
|
91
|
+
if web.signin.get_data() is None:
|
|
94
92
|
return dict(error='signin_file_data is None.')
|
|
95
93
|
form = await req.json()
|
|
96
94
|
try:
|
|
@@ -101,10 +99,10 @@ class Users(feature.WebFeature):
|
|
|
101
99
|
|
|
102
100
|
@app.post('/users/apikey/del')
|
|
103
101
|
async def users_apikey_del(req:Request, res:Response):
|
|
104
|
-
signin = web.check_signin(req, res)
|
|
102
|
+
signin = web.signin.check_signin(req, res)
|
|
105
103
|
if signin is not None:
|
|
106
104
|
return signin
|
|
107
|
-
if web.
|
|
105
|
+
if web.signin.get_data() is None:
|
|
108
106
|
return dict(error='signin_file_data is None.')
|
|
109
107
|
form = await req.json()
|
|
110
108
|
try:
|
|
@@ -115,10 +113,10 @@ class Users(feature.WebFeature):
|
|
|
115
113
|
|
|
116
114
|
@app.get('/groups/list')
|
|
117
115
|
async def groups_list(req:Request, res:Response):
|
|
118
|
-
signin = web.check_signin(req, res)
|
|
116
|
+
signin = web.signin.check_signin(req, res)
|
|
119
117
|
if signin is not None:
|
|
120
118
|
return signin
|
|
121
|
-
if web.
|
|
119
|
+
if web.signin.get_data() is None:
|
|
122
120
|
return dict(error='signin_file_data is None.')
|
|
123
121
|
try:
|
|
124
122
|
return web.group_list(None)
|
|
@@ -127,10 +125,10 @@ class Users(feature.WebFeature):
|
|
|
127
125
|
|
|
128
126
|
@app.post('/groups/add')
|
|
129
127
|
async def groups_add(req:Request, res:Response):
|
|
130
|
-
signin = web.check_signin(req, res)
|
|
128
|
+
signin = web.signin.check_signin(req, res)
|
|
131
129
|
if signin is not None:
|
|
132
130
|
return signin
|
|
133
|
-
if web.
|
|
131
|
+
if web.signin.get_data() is None:
|
|
134
132
|
return dict(error='signin_file_data is None.')
|
|
135
133
|
form = await req.json()
|
|
136
134
|
try:
|
|
@@ -141,10 +139,10 @@ class Users(feature.WebFeature):
|
|
|
141
139
|
|
|
142
140
|
@app.post('/groups/edit')
|
|
143
141
|
async def groups_edit(req:Request, res:Response):
|
|
144
|
-
signin = web.check_signin(req, res)
|
|
142
|
+
signin = web.signin.check_signin(req, res)
|
|
145
143
|
if signin is not None:
|
|
146
144
|
return signin
|
|
147
|
-
if web.
|
|
145
|
+
if web.signin.get_data() is None:
|
|
148
146
|
return dict(error='signin_file_data is None.')
|
|
149
147
|
form = await req.json()
|
|
150
148
|
try:
|
|
@@ -155,10 +153,10 @@ class Users(feature.WebFeature):
|
|
|
155
153
|
|
|
156
154
|
@app.post('/groups/del')
|
|
157
155
|
async def groups_del(req:Request, res:Response):
|
|
158
|
-
signin = web.check_signin(req, res)
|
|
156
|
+
signin = web.signin.check_signin(req, res)
|
|
159
157
|
if signin is not None:
|
|
160
158
|
return signin
|
|
161
|
-
if web.
|
|
159
|
+
if web.signin.get_data() is None:
|
|
162
160
|
return dict(error='signin_file_data is None.')
|
|
163
161
|
form = await req.json()
|
|
164
162
|
try:
|
|
@@ -171,46 +169,46 @@ class Users(feature.WebFeature):
|
|
|
171
169
|
|
|
172
170
|
@app.get('/cmdrules/list')
|
|
173
171
|
async def cmdrules_list(req:Request, res:Response):
|
|
174
|
-
signin = web.check_signin(req, res)
|
|
172
|
+
signin = web.signin.check_signin(req, res)
|
|
175
173
|
if signin is not None:
|
|
176
174
|
return signin
|
|
177
|
-
if web.
|
|
175
|
+
if web.signin.get_data() is None:
|
|
178
176
|
return dict(error='signin_file_data is None.')
|
|
179
177
|
try:
|
|
180
|
-
return web.
|
|
178
|
+
return web.signin.get_data()['cmdrule']
|
|
181
179
|
except Exception as e:
|
|
182
180
|
return dict(error=str(e))
|
|
183
181
|
|
|
184
182
|
@app.get('/pathrules/list')
|
|
185
183
|
async def pathrules_list(req:Request, res:Response):
|
|
186
|
-
signin = web.check_signin(req, res)
|
|
184
|
+
signin = web.signin.check_signin(req, res)
|
|
187
185
|
if signin is not None:
|
|
188
186
|
return signin
|
|
189
|
-
if web.
|
|
187
|
+
if web.signin.get_data() is None:
|
|
190
188
|
return dict(error='signin_file_data is None.')
|
|
191
189
|
try:
|
|
192
|
-
return web.
|
|
190
|
+
return web.signin.get_data()['pathrule']
|
|
193
191
|
except Exception as e:
|
|
194
192
|
return dict(error=str(e))
|
|
195
193
|
|
|
196
194
|
@app.get('/passsetting/list')
|
|
197
195
|
async def passsetting_list(req:Request, res:Response):
|
|
198
|
-
signin = web.check_signin(req, res)
|
|
196
|
+
signin = web.signin.check_signin(req, res)
|
|
199
197
|
if signin is not None:
|
|
200
198
|
return signin
|
|
201
|
-
if web.
|
|
199
|
+
if web.signin.get_data() is None:
|
|
202
200
|
return dict(error='signin_file_data is None.')
|
|
203
201
|
try:
|
|
204
|
-
return web.
|
|
202
|
+
return web.signin.get_data()['password']
|
|
205
203
|
except Exception as e:
|
|
206
204
|
return dict(error=str(e))
|
|
207
205
|
|
|
208
206
|
@app.post('/password/change')
|
|
209
207
|
async def password_change(req:Request, res:Response):
|
|
210
|
-
signin = web.check_signin(req, res)
|
|
208
|
+
signin = web.signin.check_signin(req, res)
|
|
211
209
|
if signin is not None:
|
|
212
210
|
return signin
|
|
213
|
-
if web.
|
|
211
|
+
if web.signin.get_data() is None:
|
|
214
212
|
return dict(error='signin_file_data is None.')
|
|
215
213
|
form = await req.json()
|
|
216
214
|
try:
|
|
@@ -15,7 +15,7 @@ class VersionsCmdbox(feature.WebFeature):
|
|
|
15
15
|
"""
|
|
16
16
|
@app.get('/versions_cmdbox')
|
|
17
17
|
async def versions_cmdbox(req:Request, res:Response):
|
|
18
|
-
signin = web.check_signin(req, res)
|
|
18
|
+
signin = web.signin.check_signin(req, res)
|
|
19
19
|
if signin is not None:
|
|
20
20
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
21
21
|
logo = [version.__logo__]
|
|
@@ -16,7 +16,7 @@ class VersionsUsed(feature.WebFeature):
|
|
|
16
16
|
"""
|
|
17
17
|
@app.get('/versions_used')
|
|
18
18
|
async def versions_used(req:Request, res:Response):
|
|
19
|
-
signin = web.check_signin(req, res)
|
|
19
|
+
signin = web.signin.check_signin(req, res)
|
|
20
20
|
if signin is not None:
|
|
21
21
|
raise HTTPException(status_code=401, detail=self.DEFAULT_401_MESSAGE)
|
|
22
22
|
|
cmdbox/app/options.py
CHANGED
|
@@ -274,18 +274,16 @@ class Options:
|
|
|
274
274
|
discription_ja="コマンドを指定します。",
|
|
275
275
|
discription_en="Specify the command.",
|
|
276
276
|
choice=[])
|
|
277
|
-
self._options["
|
|
278
|
-
short="
|
|
279
|
-
discription_ja="
|
|
280
|
-
discription_en="Specify the
|
|
281
|
-
|
|
282
|
-
short="a", type=Options.T_BOOL, default=False, required=False, multi=False, hide=True, choice=[True, False],
|
|
283
|
-
discription_ja="処理結果jsonファイルを追記保存します。",
|
|
284
|
-
discription_en="Save the processing result json file by appending.")
|
|
277
|
+
self._options["tag"] = dict(
|
|
278
|
+
short="t", type=Options.T_STR, default=None, required=False, multi=True, hide=True,
|
|
279
|
+
discription_ja="このコマンドのタグを指定します。",
|
|
280
|
+
discription_en="Specify the tag for this command.",
|
|
281
|
+
choice=None)
|
|
285
282
|
|
|
286
283
|
def init_debugoption(self):
|
|
287
284
|
# デバックオプションを追加
|
|
288
285
|
self._options["debug"]["opt"] = "debug"
|
|
286
|
+
self._options["tag"]["opt"] = "tag"
|
|
289
287
|
for key, mode in self._options["cmd"].items():
|
|
290
288
|
if type(mode) is not dict:
|
|
291
289
|
continue
|
|
@@ -296,6 +294,8 @@ class Options:
|
|
|
296
294
|
c["opt"] = k
|
|
297
295
|
if "debug" not in [_o['opt'] for _o in c["choice"]]:
|
|
298
296
|
c["choice"].append(self._options["debug"])
|
|
297
|
+
if "tag" not in [_o['opt'] for _o in c["choice"]]:
|
|
298
|
+
c["choice"].append(self._options["tag"])
|
|
299
299
|
if c["opt"] not in [_o['opt'] for _o in self._options["cmd"]["choice"]]:
|
|
300
300
|
self._options["cmd"]["choice"] += [c]
|
|
301
301
|
self._options["mode"][key] = mode
|