forked from chameleonbr/node-red-contrib-jwt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jwt.html
155 lines (150 loc) · 6.06 KB
/
jwt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<script type="text/javascript">
RED.nodes.registerType('jwt sign',{
category: "function",
icon: "hash.png",
color: "#a6bbcf",
inputs: 1,
outputs: 1,
defaults: {
name: { value: "" },
topic: { value: "" },
alg: { value: "HS256" },
exp: { value: 3600, validation: RED.validators.number() },
secret: { value: "" },
key: { value: "" },
signvar: { value: "payload",required:true },
storetoken: { value: "payload" }
},
label: function() {
return this.name || "JWT Sign"
}
});
</script>
<script type="text/x-red" data-template-name="jwt sign">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
<div class="form-row">
<label for="node-input-alg"><i class="fa fa-unlock"></i> Algorithm:</label>
<select id="node-input-alg">
<option value="HS256" selected>HS256</option>
<option value="HS384">HS384</option>
<option value="HS512">HS512</option>
<option value="RS256">RS256</option>
<option value="RS384">RS384</option>
<option value="RS512">RS512</option>
</select>
</div>
<div class="form-row">
<label for="node-input-exp"><i class="fa fa-lock"></i> Expiration</label>
<input type="text" id="node-input-exp" placeholder="Expiration in seconds">
</div>
<div class="form-row">
<label for="node-input-secret"><i class="fa fa-lock"></i> Secret</label>
<input type="password" id="node-input-secret" placeholder="Secret">
</div>
<div class="form-row">
<label for="node-input-key"><i class="fa fa-file"></i> Key File</label>
<input type="text" id="node-input-key" placeholder="Key File">
</div>
<div class="form-row">
<label for="node-input-signvar"><i class="fa fa-book"></i> Sign:</label>
<select id="node-input-signvar">
<option value="payload" selected>msg.payload</option>
<option value="token">msg.token</option>
<option value="topic">msg.topic</option>
</select>
</div>
<div class="form-row">
<label for="node-input-storetoken"><i class="fa fa-book"></i> Store Token:</label>
<select id="node-input-storetoken">
<option value="payload" selected>msg.payload</option>
<option value="token">msg.token</option>
<option value="topic">msg.topic</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="jwt sign">
<p>Sign using JWT protocol</p>
<p>Sign and store result on msg.payload.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('jwt verify',{
category: "function",
icon: "hash.png",
color: "#a6bbcf",
inputs: 1,
outputs: 1,
defaults: {
name: { value: "" },
topic: { value: "" },
alg: { value: ["HS256"] },
secret: { value: "" },
key: { value: "" },
signvar: { value: "payload" },
storetoken: { value: "payload" }
},
label: function() {
return this.name || "JWT verify"
}
});
</script>
<script type="text/x-red" data-template-name="jwt verify">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
<div class="form-row">
<label for="node-input-alg"><i class="fa fa-unlock"></i> Algorithm:</label>
<select id="node-input-alg" multiple>
<option value="HS256" selected>HS256</option>
<option value="HS384">HS384</option>
<option value="HS512">HS512</option>
<option value="RS256">RS256</option>
<option value="RS384">RS384</option>
<option value="RS512">RS512</option>
<!--option value="ES256">ES256</option>
<option value="ES384">ES384</option>
<option value="ES512">ES512</option-->
</select>
</div>
<div class="form-row">
<label for="node-input-secret"><i class="fa fa-lock"></i> Secret</label>
<input type="password" id="node-input-secret" placeholder="Secret">
</div>
<div class="form-row">
<label for="node-input-key"><i class="fa fa-file"></i> Key File</label>
<input type="text" id="node-input-key" placeholder="Key File">
</div>
<div class="form-row">
<label for="node-input-signvar"><i class="fa fa-book"></i> Verify:</label>
<select id="node-input-signvar">
<option value="payload" selected>msg.payload</option>
<option value="token">msg.token</option>
<option value="topic">msg.topic</option>
<option value="bearer">Auth Bearer and Access Token Param(HTTP)</option>
</select>
</div>
<div class="form-row">
<label for="node-input-storetoken"><i class="fa fa-book"></i> Store Token:</label>
<select id="node-input-storetoken">
<option value="payload" selected>msg.payload</option>
<option value="token">msg.token</option>
<option value="topic">msg.topic</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="jwt verify">
<p>Verify JWT signature JWT</p>
<p>Verify and store result on msg.payload, topic or token.</p>
<p>Second output receive error responses from JWT lib.</p>
</script>