Skip to content

Commit 3e65bbc

Browse files
committed
Add not implemented token auth.
1 parent 7304785 commit 3e65bbc

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

routers/api/packages/api.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,10 @@ func ContainerRoutes() *web.Route {
603603
})
604604

605605
r.Get("", container.ReqContainerAccess, container.DetermineSupport)
606-
r.Get("/token", container.Authenticate)
606+
r.Group("/token", func() {
607+
r.Get("", container.Authenticate)
608+
r.Post("", container.AuthenticateNotImplemented)
609+
})
607610
r.Get("/_catalog", container.ReqContainerAccess, container.GetRepositoryList)
608611
r.Group("/{username}", func() {
609612
r.Group("/{image}", func() {

routers/api/packages/container/container.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ func Authenticate(ctx *context.Context) {
156156
})
157157
}
158158

159+
// https://distribution.github.io/distribution/spec/auth/oauth/
160+
func AuthenticateNotImplemented(ctx *context.Context) {
161+
// This optional endpoint can be used to authenticate a client.
162+
// It must implement the specification described in:
163+
// https://datatracker.ietf.org/doc/html/rfc6749
164+
// https://distribution.github.io/distribution/spec/auth/oauth/
165+
// Purpose of this stub is to respond with 404 Not Found instead of 405 Method Not Allowed.
166+
167+
ctx.Status(http.StatusNotFound)
168+
}
169+
159170
// https://docs.docker.com/registry/spec/api/#listing-repositories
160171
func GetRepositoryList(ctx *context.Context) {
161172
n := ctx.FormInt("n")

0 commit comments

Comments
 (0)