From 9ed5cc00cfcc0bcb41f8f6831064ca464583831e Mon Sep 17 00:00:00 2001 From: "m.nabokikh" Date: Wed, 24 Feb 2021 17:14:28 +0400 Subject: [PATCH] Add deprecation warning for /device/token endpoint Signed-off-by: m.nabokikh --- server/deviceflowhandlers.go | 3 +++ server/server.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/deviceflowhandlers.go b/server/deviceflowhandlers.go index eef50866..039472b8 100644 --- a/server/deviceflowhandlers.go +++ b/server/deviceflowhandlers.go @@ -152,6 +152,9 @@ func (s *Server) handleDeviceCode(w http.ResponseWriter, r *http.Request) { } func (s *Server) handleDeviceTokenGrant(w http.ResponseWriter, r *http.Request) { + s.logger.Warn(`Request to the deprecated "/device/token" endpoint was received.`) + s.logger.Warn(`The "/device/token" endpoint will be removed in a future release.`) + w.Header().Set("Content-Type", "application/json") switch r.Method { case http.MethodPost: diff --git a/server/server.go b/server/server.go index 1294ff76..63305403 100644 --- a/server/server.go +++ b/server/server.go @@ -320,7 +320,7 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy) handleFunc("/device", s.handleDeviceExchange) handleFunc("/device/auth/verify_code", s.verifyUserCode) handleFunc("/device/code", s.handleDeviceCode) - // TODO(nabokihms): deprecate and remove this endpoint, use /token instead + // TODO(nabokihms): "/device/token" endpoint is deprecated, consider using /token endpoint instead handleFunc("/device/token", s.handleDeviceTokenGrant) handleFunc(deviceCallbackURI, s.handleDeviceCallback) r.HandleFunc(path.Join(issuerURL.Path, "/callback"), func(w http.ResponseWriter, r *http.Request) {