Commit 70cd91e6 authored by ale's avatar ale

Encode the services JSON in the logout handler

parent 11f62905
Pipeline #915 passed with stages
in 1 minute and 8 seconds
......@@ -200,7 +200,7 @@ idlogout.get_services = function() {
return JSON.parse($('#services').attr('data-services'));
};
idlogout.logout_service = function(service) {
idlogout.logout_service = function(idx, service) {
var logout_url = service.url + 'sso_logout';
console.log('logging out of ' + service.name);
$.ajax({
......@@ -211,11 +211,11 @@ idlogout.logout_service = function(service) {
withCredentials: true
},
success: function() {
$('#status_'+service.idx).class('logout-status-ok').text('OK');
$('#status_'+idx).class('logout-status-ok').text('OK');
console.log('successful logout for ' + service.name);
},
error: function() {
$('#status_'+service.idx).class('logout-status-error').text('ERROR');
$('#status_'+idx).class('logout-status-error').text('ERROR');
console.log('error logging out of ' + service.name);
}
});
......@@ -224,7 +224,7 @@ idlogout.logout_service = function(service) {
idlogout.logout = function() {
var services = idlogout.get_services();
$.each(services, function(index, arg) {
idlogout.logout_service(arg);
idlogout.logout_service(index, arg);
});
};
......@@ -243,7 +243,7 @@ func staticJsLogoutJs() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "static/js/logout.js", size: 1019, mode: os.FileMode(436), modTime: time.Unix(1518961249, 0)}
info := bindataFileInfo{name: "static/js/logout.js", size: 1015, mode: os.FileMode(436), modTime: time.Unix(1518963191, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
......@@ -1276,7 +1276,7 @@ var _templatesLogoutHtml = []byte(`{{template "header" .}}
{{end}}
</ul>
<div id="#services" data-services="[{{range $i, $svc := .Services}}{{if gt $i 0}},{{end}}{%22idx%22:{{$i}},%22name%22:%22{{$svc.Name}}%22,%22url%22:%22{{$svc.URL}}%22}{{end}}]"></div>
<div id="services" data-services="{{.ServicesJSON}}"></div>
</div>
{{else}}
......@@ -1313,7 +1313,7 @@ func templatesLogoutHtml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "templates/logout.html", size: 1505, mode: os.FileMode(436), modTime: time.Unix(1518961241, 0)}
info := bindataFileInfo{name: "templates/logout.html", size: 1381, mode: os.FileMode(436), modTime: time.Unix(1518963171, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
......@@ -1344,7 +1344,7 @@ var _templatesPageHtml = []byte(`{{define "header"}}<!DOCTYPE html>
<script type="text/javascript" src="/static/js/u2f.js" integrity="sha384-vd6lytRvVm189G5gr34wlOvN672vVBceTZqV+lTSeec0DBLc0GlWLyKDHc6mrIZS"></script>
{{end}}
{{if .IncludeLogoutScripts}}
<script type="text/javascript" src="/static/js/logout.js" integrity="sha384-+V9VUvMMX5z37HxqZoSrTvQ2vHEH3OPksWy9gyQYfeWdzxtmpNR1r/z3+i0roLxS"></script>
<script type="text/javascript" src="/static/js/logout.js" integrity="sha384-swhUuZtRhByZOwc9Obn/dcrmcTXonO4xFuaIZKU3X8Ge/DSv3b+O4rL0+rjzRiRz"></script>
{{end}}
</body>
</html>
......@@ -1361,7 +1361,7 @@ func templatesPageHtml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "templates/page.html", size: 1686, mode: os.FileMode(436), modTime: time.Unix(1518961516, 0)}
info := bindataFileInfo{name: "templates/page.html", size: 1686, mode: os.FileMode(436), modTime: time.Unix(1518963201, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
......
......@@ -5,6 +5,7 @@ package server
import (
"encoding/gob"
"encoding/json"
"fmt"
"html/template"
"io"
......@@ -234,8 +235,8 @@ func (h *Server) handleHomepage(w http.ResponseWriter, req *http.Request, sessio
}
type logoutServiceInfo struct {
URL string
Name string
URL string `json:"url"`
Name string `json:"name"`
}
func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request, session *authSession) {
......@@ -255,6 +256,7 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request, session
if req.Method == "POST" {
data["IsPOST"] = true
data["IncludeLogoutScripts"] = true
data["ServicesJSON"], _ = json.Marshal(svcs)
// Clear the local session.
httpSession, _ := h.authSessionStore.Get(req, authSessionKey)
......
......@@ -4,7 +4,7 @@ idlogout.get_services = function() {
return JSON.parse($('#services').attr('data-services'));
};
idlogout.logout_service = function(service) {
idlogout.logout_service = function(idx, service) {
var logout_url = service.url + 'sso_logout';
console.log('logging out of ' + service.name);
$.ajax({
......@@ -15,11 +15,11 @@ idlogout.logout_service = function(service) {
withCredentials: true
},
success: function() {
$('#status_'+service.idx).class('logout-status-ok').text('OK');
$('#status_'+idx).class('logout-status-ok').text('OK');
console.log('successful logout for ' + service.name);
},
error: function() {
$('#status_'+service.idx).class('logout-status-error').text('ERROR');
$('#status_'+idx).class('logout-status-error').text('ERROR');
console.log('error logging out of ' + service.name);
}
});
......@@ -28,7 +28,7 @@ idlogout.logout_service = function(service) {
idlogout.logout = function() {
var services = idlogout.get_services();
$.each(services, function(index, arg) {
idlogout.logout_service(arg);
idlogout.logout_service(index, arg);
});
};
......
......@@ -32,7 +32,7 @@
{{end}}
</ul>
<div id="#services" data-services="[{{range $i, $svc := .Services}}{{if gt $i 0}},{{end}}{%22idx%22:{{$i}},%22name%22:%22{{$svc.Name}}%22,%22url%22:%22{{$svc.URL}}%22}{{end}}]"></div>
<div id="services" data-services="{{.ServicesJSON}}"></div>
</div>
{{else}}
......
......@@ -24,7 +24,7 @@
<script type="text/javascript" src="/static/js/u2f.js" integrity="sha384-vd6lytRvVm189G5gr34wlOvN672vVBceTZqV+lTSeec0DBLc0GlWLyKDHc6mrIZS"></script>
{{end}}
{{if .IncludeLogoutScripts}}
<script type="text/javascript" src="/static/js/logout.js" integrity="sha384-+V9VUvMMX5z37HxqZoSrTvQ2vHEH3OPksWy9gyQYfeWdzxtmpNR1r/z3+i0roLxS"></script>
<script type="text/javascript" src="/static/js/logout.js" integrity="sha384-swhUuZtRhByZOwc9Obn/dcrmcTXonO4xFuaIZKU3X8Ge/DSv3b+O4rL0+rjzRiRz"></script>
{{end}}
</body>
</html>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment