MCPcopy
hub / github.com/OWASP/Go-SCP / protectedProfile

Function protectedProfile

src/session-management/session.go:97–109  ·  view source on GitHub ↗

only viewable if the client has a valid token

(res http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

95
96// only viewable if the client has a valid token
97func protectedProfile(res http.ResponseWriter, req *http.Request) {
98 claims, ok := req.Context().Value(MyKey).(Claims)
99 if !ok {
100 res.Header().Set("Content-Type", "text/html")
101 fmt.Fprint(res, "Unauthorized - Please login <br>")
102 fmt.Fprintf(res, "<a href=\"login\"> Login </a>")
103
104 return
105 }
106 res.Header().Set("Content-Type", "text/html")
107 fmt.Fprintf(res, "Hello %s <br>", claims.Username)
108 fmt.Fprintf(res, "<a href=\"logout\"> Logout </a>")
109}
110
111// deletes the cookie
112func logout(res http.ResponseWriter, req *http.Request) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected