Skip to content

Commit

Permalink
Removes jwt token from localStorage and store in the http cookie
Browse files Browse the repository at this point in the history
Signed-off-by: Shiv Verma <[email protected]>
  • Loading branch information
pratap0007 committed Mar 10, 2022
1 parent 1f8cdd1 commit da61bf3
Show file tree
Hide file tree
Showing 32 changed files with 900 additions and 552 deletions.
20 changes: 7 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,8 @@ var _ = Service("rating", func() {

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

Response(StatusOK)
Response("not-found", StatusNotFound)
Expand All @@ -58,22 +55,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 @@ -158,23 +158,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 @@ -200,29 +191,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 @@ -251,8 +231,6 @@ paths:
$ref: '#/definitions/RatingUpdateInternalErrorResponseBody'
schemes:
- https
security:
- jwt_header_Authorization: []
/schema/swagger.json:
get:
tags:
Expand Down
2 changes: 1 addition & 1 deletion api/gen/http/openapi3.json

Large diffs are not rendered by default.

40 changes: 22 additions & 18 deletions api/gen/http/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ paths:
description: ID of a resource
example: 17081788299688252022
example: 11089527418313215274
- name: accessToken
in: cookie
description: Session ID
allowEmptyValue: true
required: true
schema:
type: string
description: Session ID
example: Ipsum tenetur unde et amet eum hic.
example: Consequatur explicabo.
responses:
"200":
description: OK response.
Expand Down Expand Up @@ -298,14 +308,6 @@ paths:
id: 3F1FKVRR
message: Value of ID must be an integer
name: bad_request
security:
- jwt_header_Authorization:
- rating:read
- rating:write
- agent:create
- catalog:refresh
- config:refresh
- refresh:token
put:
tags:
- rating
Expand All @@ -320,8 +322,18 @@ paths:
schema:
type: integer
description: ID of a resource
example: 9739613307880178607
example: 2070151992422837927
example: 8741701717887354389
example: 12793890618565952106
- name: accessToken
in: cookie
description: Session ID
allowEmptyValue: true
required: true
schema:
type: string
description: Session ID
example: Ipsa minus ut.
example: Dolor sit.
requestBody:
required: true
content:
Expand Down Expand Up @@ -373,14 +385,6 @@ paths:
id: 3F1FKVRR
message: Value of ID must be an integer
name: bad_request
security:
- jwt_header_Authorization:
- rating:read
- rating:write
- agent:create
- catalog:refresh
- config:refresh
- refresh:token
/schema/swagger.json:
get:
tags:
Expand Down
16 changes: 8 additions & 8 deletions api/gen/http/rating/client/cli.go

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

23 changes: 10 additions & 13 deletions api/gen/http/rating/client/encode_decode.go

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

Loading

0 comments on commit da61bf3

Please sign in to comment.