Skip to content

Commit 29f06eb

Browse files
authored
feat: add DOZZLE_AUTH_LOGOUT_URL support for ForwarderProxy (#4151)
1 parent 020342a commit 29f06eb

File tree

8 files changed

+27
-5
lines changed

8 files changed

+27
-5
lines changed

assets/components/Links.vue

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
{{ config.user.email }}
3434
</div>
3535
</div>
36-
<ul v-if="config.authProvider === 'simple'" class="menu mt-4 p-0">
36+
<ul v-if="config.authProvider === 'simple' || config.logoutUrl" class="menu mt-4 p-0">
3737
<li>
3838
<button @click.prevent="logout()" class="text-primary p-2">
3939
<material-symbols:logout />
@@ -46,11 +46,17 @@
4646
</div>
4747
</template>
4848
<script lang="ts" setup>
49+
const { logoutUrl } = config;
50+
4951
async function logout() {
50-
await fetch(withBase("/api/token"), {
51-
method: "DELETE",
52-
});
52+
if (logoutUrl) {
53+
location.href = logoutUrl;
54+
} else {
55+
await fetch(withBase("/api/token"), {
56+
method: "DELETE",
57+
});
5358
54-
location.reload();
59+
location.reload();
60+
}
5561
}
5662
</script>

assets/stores/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface Config {
1010
hostname: string;
1111
hosts: Host[];
1212
authProvider: "simple" | "none" | "forward-proxy";
13+
logoutUrl?: string;
1314
enableActions: boolean;
1415
enableShell: boolean;
1516
enableDownload: boolean;

docs/guide/authentication.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ In this mode, Dozzle expects the following headers:
211211
- `Remote-Filter` to be a comma-separated list of filters allowed for user.
212212
- `Remote-Roles` to be a comma-separated list of roles allowed for user.
213213

214+
Additionally, you can configure a logout URL with:
215+
216+
```yaml
217+
DOZZLE_AUTH_LOGOUT_URL: http://oauth2.example.ru/oauth2/sign_out
218+
```
219+
214220
### Setting up Dozzle with Authelia
215221

216222
[Authelia](https://www.authelia.com/) is an open-source authentication and authorization server and portal fulfilling the identity and access management. While setting up Authelia is out of scope for this section, the configuration can be shared as an example for setting up Dozzle with Authelia.

docs/guide/supported-env-vars.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Configurations can be done with flags or environment variables. The table below
1818
| `--auth-header-name` | `DOZZLE_AUTH_HEADER_NAME` | `Remote-Name` |
1919
| `--auth-header-filter` | `DOZZLE_AUTH_HEADER_FILTER` | `Remote-Filter` |
2020
| `--auth-header-roles` | `DOZZLE_AUTH_HEADER_ROLES` | `Remote-Roles` |
21+
| `--auth-logout-url` | `DOZZLE_AUTH_LOGOUT_URL` | `""` |
2122
| `--enable-actions` | `DOZZLE_ENABLE_ACTIONS` | `false` |
2223
| `--enable-shell` | `DOZZLE_ENABLE_SHELL` | `false` |
2324
| `--disable-avatars` | `DOZZLE_DISABLE_AVATARS` | `false` |

internal/support/cli/args.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type Args struct {
2222
AuthHeaderName string `arg:"--auth-header-name,env:DOZZLE_AUTH_HEADER_NAME" default:"Remote-Name" help:"sets the HTTP Header to use for name in Forward Proxy configuration."`
2323
AuthHeaderFilter string `arg:"--auth-header-filter,env:DOZZLE_AUTH_HEADER_FILTER" default:"Remote-Filter" help:"sets the HTTP Header to use for filtering in Forward Proxy configuration."`
2424
AuthHeaderRoles string `arg:"--auth-header-roles,env:DOZZLE_AUTH_HEADER_ROLES" default:"Remote-Roles" help:"sets the HTTP Header to use for roles in Forward Proxy configuration."`
25+
AuthLogoutUrl string `arg:"--auth-logout-url,env:DOZZLE_AUTH_LOGOUT_URL" help:"sets the Logout URL used with Forward Proxy."`
2526
EnableActions bool `arg:"--enable-actions,env:DOZZLE_ENABLE_ACTIONS" default:"false" help:"enables essential actions on containers from the web interface."`
2627
EnableShell bool `arg:"--enable-shell,env:DOZZLE_ENABLE_SHELL" default:"false" help:"enables shell access to containers from the web interface."`
2728
DisableAvatars bool `arg:"--disable-avatars,env:DOZZLE_DISABLE_AVATARS" default:"false" help:"disables avatars for authenticated users."`

internal/web/index.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"html/template"
55
"io"
66
"sort"
7+
"strings"
78

89
"encoding/json"
910

@@ -54,6 +55,10 @@ func (h *handler) executeTemplate(w http.ResponseWriter, req *http.Request) {
5455
config["enableDownload"] = true
5556
}
5657

58+
if h.config.Authorization.Provider == FORWARD_PROXY && strings.TrimSpace(h.config.Authorization.LogoutUrl) != "" {
59+
config["logoutUrl"] = strings.TrimSpace(h.config.Authorization.LogoutUrl)
60+
}
61+
5762
config["authProvider"] = h.config.Authorization.Provider
5863
config["version"] = h.config.Version
5964
config["hostname"] = h.config.Hostname

internal/web/routes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type Authorization struct {
5252
Provider AuthProvider
5353
Authorizer Authorizer
5454
TTL time.Duration
55+
LogoutUrl string
5556
}
5657

5758
type Authorizer interface {

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func createServer(args cli.Args, hostService web.HostService) *http.Server {
208208
Provider: provider,
209209
Authorizer: authorizer,
210210
TTL: authTTL,
211+
LogoutUrl: args.AuthLogoutUrl,
211212
},
212213
EnableActions: args.EnableActions,
213214
EnableShell: args.EnableShell,

0 commit comments

Comments
 (0)