Commit c1eedff
authored
security: server-side gate — password moves to GATE_PASSWORD env (#6)
The password was hardcoded in app.js (const === '1234') — anyone
reading the asset had the secret, and the check was client-side only,
so the WebSocket was reachable without solving the gate at all.
Now:
- agent-bridge reads GATE_PASSWORD from env; unset = open bridge
(loopback/local use, previous behavior)
- POST /auth validates the password and returns a per-run random
token; the secret exists only in the process env
- WebSocket upgrades must carry ?token= when a password is set;
rejects with close 1008
- app.js: unlock() exchanges the password via /auth, stores the
token, attaches it to the WS URL; a 1008 close clears the token
and re-shows the gate (no reconnect loop)
- '1234' and the chat-pass localStorage flag are gone from the
codebase entirely1 parent df64bf0 commit c1eedff
2 files changed
Lines changed: 62 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
134 | | - | |
135 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
136 | 152 | | |
137 | | - | |
138 | 153 | | |
139 | 154 | | |
140 | 155 | | |
| |||
152 | 167 | | |
153 | 168 | | |
154 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
155 | 176 | | |
156 | | - | |
157 | | - | |
158 | 177 | | |
159 | 178 | | |
160 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 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 | + | |
105 | 122 | | |
106 | 123 | | |
107 | | - | |
108 | 124 | | |
109 | 125 | | |
110 | 126 | | |
| |||
748 | 764 | | |
749 | 765 | | |
750 | 766 | | |
751 | | - | |
| 767 | + | |
| 768 | + | |
752 | 769 | | |
753 | 770 | | |
754 | 771 | | |
755 | 772 | | |
756 | 773 | | |
| 774 | + | |
757 | 775 | | |
758 | 776 | | |
759 | 777 | | |
| |||
764 | 782 | | |
765 | 783 | | |
766 | 784 | | |
767 | | - | |
| 785 | + | |
768 | 786 | | |
769 | 787 | | |
770 | 788 | | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
771 | 796 | | |
772 | 797 | | |
773 | 798 | | |
| |||
0 commit comments