Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The JWTAuth security scheme should get the token from Cookie as well #2965

Open
PuneetPunamiya opened this issue Dec 14, 2021 · 5 comments
Open

Comments

@PuneetPunamiya
Copy link

Currently the JWTAuth security scheme assumes the token from the HTTP header only

With the latest release of adding cookie in the design, the The JWTAuth security scheme should be able to read the token from cookie also

For example

var _ = Service("rating", func() {
	Description("The rating service exposes endpoints to read and write user's rating for resources")

	Error("not-found", ErrorResult, "Resource Not Found Error")
	Error("internal-error", ErrorResult, "Internal server error")
	Error("invalid-token", ErrorResult, "Invalid User token")
	Error("invalid-scopes", ErrorResult, "Invalid User scope")

	Method("Get", func() {
		Description("Find user's rating for a resource")
		Security(types.JWTAuth, func() {
			Scope("rating:read")
		})
		Payload(func() {
			Attribute("id", UInt, "ID of a resource")
			Token("token", String, "JWT")
			Required("id", "token")
		})
		Result(func() {
			Attribute("rating", Int, "User rating for resource", func() {
				Example("rating", 4)
			})
			Required("rating")
		})

		HTTP(func() {
			GET("/resource/{id}/rating")
			Cookie("token:Authorization")

			Response("not-found", StatusNotFound)
			Response("internal-error", StatusInternalServerError)
			Response("invalid-token", StatusUnauthorized)
			Response("invalid-scopes", StatusForbidden)
		})
	})
})

On running the goa-gen command it gets executed correctly
but on running the api it gives the following error

# github.com/tektoncd/hub/api/gen/http/rating/server
gen/http/rating/server/encode_decode.go:41:4: token redeclared in this block
	previous declaration at gen/http/rating/server/encode_decode.go:40:4
gen/http/rating/server/types.go:295:43: duplicate argument token
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@PuneetPunamiya
Copy link
Author

/reopen

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@jace-ys
Copy link

jace-ys commented Oct 31, 2024

I'm quite keen for this feature to be implemented. Could this be re-opened please? @raphael

@raphael raphael reopened this Oct 31, 2024
@raphael
Copy link
Member

raphael commented Oct 31, 2024

Yes, I reopened it. I also disabled the stale issue bot as it seems to be doing more harm than good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants