Add logout

This commit is contained in:
Mustafa Gezen 2023-08-26 03:08:15 +02:00
parent c02a30aaa8
commit 72431e48a3
2 changed files with 19 additions and 0 deletions

View File

@ -497,6 +497,22 @@ func FrontendServer(info *FrontendInfo, embedfs *embed.FS) error {
// Redirect to self, this is due to the "root" not being / for all apps
http.Redirect(w, r, info.Self, http.StatusFound)
})
// Handle logout
http.HandleFunc(prefix+"/auth/oidc/logout", func(w http.ResponseWriter, r *http.Request) {
// Delete the auth cookie
http.SetCookie(w, &http.Cookie{
Name: frontendAuthCookieKey,
Value: "",
Path: "/",
MaxAge: -1,
// secure if self is https
Secure: strings.HasPrefix(info.Self, "https://"),
})
// Redirect to self, this is due to the "root" not being / for all apps
http.Redirect(w, r, info.Self, http.StatusFound)
})
}
var handler http.Handler = nil

View File

@ -46,6 +46,9 @@ export const App = () => {
Mship Admin
</Typography>
<Box sx={{ flexGrow: 1, textAlign: 'right' }}>
<Button className="native-link" href="/admin/auth/oidc/logout" variant="primary">
Logout
</Button>
<Button className="native-link" href="/" variant="primary">
Go back to Mship
</Button>