Skip to content

Commit f3711a3

Browse files
committed
Reapply "Add example for plugin_user"
This reverts commit 8def8f6.
1 parent 8def8f6 commit f3711a3

File tree

3 files changed

+46
-24
lines changed

3 files changed

+46
-24
lines changed

manifest.master.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ extensions:
8181
- type: "value"
8282
value: "%info.json%"
8383

84+
dump/plugin_user:
85+
plugin_user:
86+
# reference a plugin defined baseconfig
87+
base_config: "user.api_user"
88+
exec:
89+
service: "python3"
90+
commands:
91+
- prog: "python3"
92+
stdin:
93+
type: "body"
94+
stdout:
95+
type: "body"
96+
args:
97+
- type: "value"
98+
value: "%_exec.pluginDir%/server/extension/plugin_user.py"
99+
- type: "value"
100+
value: "%info.json%"
101+
84102
dump/error:
85103
exec:
86104
service: "node"
@@ -364,6 +382,8 @@ callbacks:
364382
- type: "value"
365383
value: "%_exec.pluginDir%/server/validation_errors/validation_errors.js"
366384
bounce:
385+
plugin_user:
386+
optional: true
367387
exec:
368388
service: "node"
369389
commands:
@@ -473,6 +493,7 @@ collection_upload:
473493
# value: "%_exec.pluginDir%/server/collection/filename_copy/config_check.js"
474494

475495
# base config extension. These parameters will be accessible via /api/config.
496+
476497
base_config:
477498
- name: comment
478499
parameters:
@@ -485,6 +506,10 @@ base_config:
485506
type: bool
486507
data:
487508
type: json
509+
- name: user
510+
parameters:
511+
api_user:
512+
type: user
488513

489514
system_rights:
490515
- name: example_right
@@ -516,29 +541,6 @@ system_rights:
516541
- name: preview-versions
517542
type: preview-versions
518543

519-
# hook for the plugin scheduler
520-
scheduler:
521-
# name of this scheduler plugin
522-
example: # "task"
523-
plugin_user:
524-
# set to true to require a plugin user to be set in the plugin manager
525-
require: true
526-
callbacks:
527-
run:
528-
exec:
529-
service: "python3"
530-
commands:
531-
- prog: "python3"
532-
stdin:
533-
type: body
534-
stdout:
535-
type: body
536-
args:
537-
- type: "value"
538-
value: "%_exec.pluginDir%/server/scheduled/example.py"
539-
- type: "value"
540-
value: "%info.json%"
541-
542544
custom_types:
543545
example:
544546
mapping:

server/extension/plugin_user.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import json, sys, requests
2+
3+
parm = json.loads(sys.argv[1])
4+
out = {
5+
"api_user": parm["api_user"],
6+
"api_user_access_token": parm["api_user_access_token"],
7+
}
8+
9+
if "plugin_user_access_token" in parm:
10+
out["plugin_user_access_token"] = parm["plugin_user_access_token"]
11+
out["plugin_user"] = parm["plugin_user"]
12+
13+
# get plugin/manage (needs system right)
14+
response = requests.get(parm["api_url"]+"/api/v1/plugin/manage", headers={
15+
"Authorization": "Bearer "+out["plugin_user_access_token"]
16+
})
17+
out["plugin_status_code"] = response.status_code
18+
19+
print(json.dumps(out, indent = 2))
20+
sys.exit(0)

server/extension/signature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def check_sig(headers, hname, body):
99
m = re.match('(sha(1|256))=([0-9a-f]+)', h)
1010
if not m:
1111
return "invalid header format: " + h
12-
12+
1313
hhash = hmac.new(
1414
SECRET.encode('utf-8'),
1515
body.encode('utf-8'),

0 commit comments

Comments
 (0)