Esempio n. 1
0
func Secure(w http.ResponseWriter, r *http.Request) {
	_, ok := sess.Authorized(w, r)
	if !ok {
		fmt.Fprintf(w, "You are not autorized. Please visit the login page")
		return
	}
	fmt.Fprintf(w, "You are now viewing secure data")
	return
}
Esempio n. 2
0
func AdminAll(w http.ResponseWriter, r *http.Request) {
	role, ok := sess.Authorized(w, r)
	if !ok || role != "admin" {
		fmt.Fprintf(w, "You are not autorized as admin. Please visit the login page")
		return
	}
	c := sess.GetAll(r)
	fmt.Fprintf(w, "Session Cookies:    %v", c)
	return
}
Esempio n. 3
0
func Admin(w http.ResponseWriter, r *http.Request) {
	role, ok := sess.Authorized(w, r)
	if !ok || role != "admin" {
		fmt.Printf("ROLE: %q0\n", role)
		fmt.Fprintf(w, "You are not autorized as admin. Please visit the login page")
		return
	}
	fmt.Fprintf(w, "You are now viewing admin data")
	return
}
Esempio n. 4
0
func SecureAll(w http.ResponseWriter, r *http.Request) {
	_, ok := sess.Authorized(w, r)
	if !ok {
		fmt.Fprintf(w, "You are not autorized. Please visit the login page")
		return
	}
	c := sess.GetAll(r)
	fmt.Fprintf(w, "Session Cookies:    %v", c)
	return
}
Esempio n. 5
0
func AdminPut(w http.ResponseWriter, r *http.Request) {
	role, ok := sess.Authorized(w, r)
	if !ok || role != "admin" {
		fmt.Fprintf(w, "You are not autorized as admin. Please visit the login page")
		return
	}
	count++
	key := fmt.Sprintf("KEY %d", count)
	val := fmt.Sprintf("VALUE %d", count)
	sess.Put(w, r, key, val)
	fmt.Fprintf(w, "Set Cookie: %s, %s", key, val)
	return
}