コード例 #1
0
ファイル: handler.go プロジェクト: thanzen/hydra
func (h *Handler) SetRoutes(r *mux.Router, extractor func(h hydcon.ContextHandler) hydcon.ContextHandler) {
	r.Handle("/oauth2/connections", hydcon.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
		h.m.IsAuthorized(connectionsPermission, "create", nil),
	).ThenFunc(h.Create)).Queries("subject", "{subject}").Methods("POST")

	r.Handle("/oauth2/connections", hydcon.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
	).ThenFunc(h.Find)).Queries("subject", "{subject}").Methods("GET")

	r.Handle("/oauth2/connections/{id}", hydcon.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
	).ThenFunc(h.Get)).Methods("GET")

	r.Handle("/oauth2/connections/{id}", hydcon.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
	).ThenFunc(h.Delete)).Methods("DELETE")
}
コード例 #2
0
ファイル: handler.go プロジェクト: thanzen/hydra
func (h *Handler) SetRoutes(r *mux.Router, extractor func(h hctx.ContextHandler) hctx.ContextHandler) {
	r.Handle("/allowed", hctx.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
	).ThenFunc(h.Granted)).Methods("POST")

	r.Handle("/policies", hctx.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
		h.m.IsAuthorized("rn:hydra:policies", "create", nil),
	).ThenFunc(h.Create)).Methods("POST")

	//	r.Handle("/policies", hctx.NewContextAdapter(
	//		context.Background(),
	//		extractor,
	//		h.m.IsAuthenticated,
	//	).ThenFunc(h.FindBySubject)).Query("subject").Methods("GET")

	r.Handle("/policies/{id}", hctx.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
	).ThenFunc(h.Get)).Methods("GET")

	r.Handle("/policies/{id}", hctx.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
	).ThenFunc(h.Delete)).Methods("DELETE")
}
コード例 #3
0
ファイル: handler.go プロジェクト: thanzen/hydra
func (h *Handler) SetRoutes(r *mux.Router) {
	h.server = osin.NewServer(h.OAuthConfig, h.OAuthStore)
	h.server.AccessTokenGen = h.JWT

	r.HandleFunc("/oauth2/auth", h.AuthorizeHandler)
	r.HandleFunc("/oauth2/token", h.TokenHandler)
	r.HandleFunc("/oauth2/info", h.InfoHandler)
	r.HandleFunc("/oauth2/introspect", h.IntrospectHandler)
}
コード例 #4
0
ファイル: handler.go プロジェクト: thanzen/hydra
func (h *Handler) SetRoutes(r *mux.Router, extractor func(h hydcon.ContextHandler) hydcon.ContextHandler) {
	r.Handle("/clients", hydcon.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
		h.m.IsAuthorized("rn:hydra:clients", "create", nil),
	).ThenFunc(h.Create)).Methods("POST")

	r.Handle("/clients/{id}", hydcon.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
	).ThenFunc(h.Get)).Methods("GET")

	r.Handle("/clients/{id}", hydcon.NewContextAdapter(
		context.Background(),
		extractor,
		h.m.IsAuthenticated,
	).ThenFunc(h.Delete)).Methods("DELETE")
}