Exemple #1
0
func (ss *ServerSuite) SetUpTest(c *C) {
	s := server.NewAuthServer(mem.NewStore())
	s.Schemes.Register(&MockScheme{})
	s.HandleFunc("/whoami", func(w http.ResponseWriter, r *http.Request) {
		user, err := s.Authenticate(r)
		if err == ErrUnauthorized {
			http.Error(w, err.Error(), http.StatusUnauthorized)
			return
		} else if err != nil {
			http.Error(w, "Server error", http.StatusInternalServerError)
			return
		}
		fmt.Fprintf(w, "%s", user.String())
	})
	ss.Server = httptest.NewServer(s)
}
Exemple #2
0
func NewGroupServer(store rbac.Store) *GroupServer {
	s := &GroupServer{server.NewAuthServer(store)}
	s.HandleFunc("/{group}/", s.HandleGroup)
	s.HandleFunc("/{group}/{user}/", s.HandleUser)
	return s
}