mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-07-06 20:37:54 +02:00
add support for {{.Origin}} in proxy response handler
Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
+12
-1
@@ -3658,8 +3658,19 @@ func (m *ProxyHandler) createResponseFromRule(rule service.ProxyServiceResponseR
|
||||
Request: req,
|
||||
}
|
||||
|
||||
// set headers
|
||||
// set headers with support for {{.Origin}} interpolation
|
||||
requestOrigin := req.Header.Get("Origin")
|
||||
for name, value := range rule.Headers {
|
||||
// support {{.Origin}} placeholder to echo back the request's origin header
|
||||
// this is useful for cors when credentials mode is 'include' and wildcard '*' is not allowed
|
||||
if strings.Contains(value, "{{.Origin}}") {
|
||||
if requestOrigin != "" {
|
||||
value = strings.ReplaceAll(value, "{{.Origin}}", requestOrigin)
|
||||
} else {
|
||||
// if no origin header present, skip this header
|
||||
continue
|
||||
}
|
||||
}
|
||||
resp.Header.Set(name, value)
|
||||
}
|
||||
|
||||
|
||||
@@ -2114,18 +2114,21 @@
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<span class="form-hint"
|
||||
>Use <code>{'{{.Origin}}'}</code> to echo the request's Origin header</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field-wrapper checkbox-wrapper">
|
||||
<label class="checkbox-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={rule.forward}
|
||||
bind:checked={rule.forward}
|
||||
class="checkbox-input"
|
||||
on:change={(e) => {
|
||||
rule.forward = e.currentTarget.checked;
|
||||
configData = configData;
|
||||
}}
|
||||
class="checkbox-input"
|
||||
/>
|
||||
<span class="checkbox-text">Forward to target</span>
|
||||
</label>
|
||||
@@ -2884,13 +2887,16 @@
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<span class="form-hint"
|
||||
>Use <code>{'{{.Origin}}'}</code> to echo the request's Origin header</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field-wrapper checkbox-wrapper">
|
||||
<label class="checkbox-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={rule.forward}
|
||||
bind:checked={rule.forward}
|
||||
on:change={(e) => {
|
||||
rule.forward = e.currentTarget.checked;
|
||||
configData = configData;
|
||||
|
||||
Reference in New Issue
Block a user