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

Stores the jwt token in a http cookie #354

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions api/design/rating.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package design

import (
"github.com/tektoncd/hub/api/design/types"
. "goa.design/goa/v3/dsl"
)

Expand All @@ -29,13 +28,10 @@ var _ = Service("rating", func() {

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")
Attribute("session", String, "Session ID")
Required("id", "session")
})
Result(func() {
Attribute("rating", Int, "User rating for resource", func() {
Expand All @@ -46,7 +42,7 @@ var _ = Service("rating", func() {

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

Response(StatusOK)
Response("not-found", StatusNotFound)
Expand All @@ -58,22 +54,19 @@ var _ = Service("rating", func() {

Method("Update", func() {
Description("Update user's rating for a resource")
Security(types.JWTAuth, func() {
Scope("rating:write")
})
Payload(func() {
Attribute("id", UInt, "ID of a resource")
Attribute("rating", UInt, "User rating for resource", func() {
Minimum(0)
Maximum(5)
})
Token("token", String, "JWT")
Required("id", "token", "rating")
Attribute("session", String, "Session ID")
Required("id", "rating", "session")
})

HTTP(func() {
PUT("/resource/{id}/rating")
Header("token:Authorization")
Cookie("session:accessToken")

Response(StatusOK)
Response("not-found", StatusNotFound)
Expand Down
32 changes: 16 additions & 16 deletions api/gen/http/cli/hub/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/openapi.json

Large diffs are not rendered by default.

26 changes: 2 additions & 24 deletions api/gen/http/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -347,23 +347,14 @@ paths:
tags:
- rating
summary: Get rating
description: |-
Find user's rating for a resource

**Required security scopes for jwt**:
* `rating:read`
description: Find user's rating for a resource
operationId: rating#Get
parameters:
- name: id
in: path
description: ID of a resource
required: true
type: integer
- name: Authorization
in: header
description: JWT
required: true
type: string
responses:
"200":
description: OK response.
Expand All @@ -389,29 +380,18 @@ paths:
$ref: '#/definitions/RatingGetInternalErrorResponseBody'
schemes:
- https
security:
- jwt_header_Authorization: []
put:
tags:
- rating
summary: Update rating
description: |-
Update user's rating for a resource

**Required security scopes for jwt**:
* `rating:write`
description: Update user's rating for a resource
operationId: rating#Update
parameters:
- name: id
in: path
description: ID of a resource
required: true
type: integer
- name: Authorization
in: header
description: JWT
required: true
type: string
- name: UpdateRequestBody
in: body
required: true
Expand Down Expand Up @@ -440,8 +420,6 @@ paths:
$ref: '#/definitions/RatingUpdateInternalErrorResponseBody'
schemes:
- https
security:
- jwt_header_Authorization: []
/resource/{id}/versions:
get:
tags:
Expand Down
2 changes: 1 addition & 1 deletion api/gen/http/openapi3.json

Large diffs are not rendered by default.

Loading