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 1, 2022
1 parent 5891295 commit 8b442f8
Show file tree
Hide file tree
Showing 28 changed files with 720 additions and 527 deletions.
22 changes: 9 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,11 @@ 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")
// Token("token", String, "JWT")
Attribute("session", String, "Session ID")
Required("id", "session")
})
Result(func() {
Attribute("rating", Int, "User rating for resource", func() {
Expand All @@ -46,7 +43,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 +56,20 @@ 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")
// 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 @@ -371,23 +371,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 @@ -413,29 +404,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 @@ -464,8 +444,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.

56 changes: 30 additions & 26 deletions api/gen/http/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ paths:
type: array
items:
type: string
example: Aliquam voluptates illo.
example: Officia velit aliquid.
description: Catalogs of resource to filter by
example:
- tekton
Expand All @@ -273,7 +273,7 @@ paths:
type: array
items:
type: string
example: Illum et ut pariatur similique.
example: Saepe sed.
description: Category associated with a resource to filter by
example:
- build
Expand All @@ -289,7 +289,7 @@ paths:
type: array
items:
type: string
example: Laudantium nostrum quia totam magni reprehenderit maxime.
example: Ab beatae est magnam eveniet nihil et.
description: Kinds of resource to filter by
example:
- task
Expand All @@ -305,7 +305,7 @@ paths:
type: array
items:
type: string
example: Velit itaque dolores dolor esse.
example: Ex voluptas voluptas.
description: Tags associated with a resource to filter by
example:
- image
Expand All @@ -321,7 +321,7 @@ paths:
type: array
items:
type: string
example: Velit aliquid praesentium saepe sed optio ab.
example: Non molestiae illo aut numquam.
description: Platforms associated with a resource to filter by
example:
- linux/s390x
Expand All @@ -347,7 +347,7 @@ paths:
type: string
description: Strategy used to find matching resources
default: contains
example: exact
example: contains
enum:
- exact
- contains
Expand Down Expand Up @@ -500,11 +500,11 @@ paths:
schema:
type: string
description: kind of resource
example: pipeline
example: task
enum:
- task
- pipeline
example: pipeline
example: task
- name: name
in: path
description: Name of resource
Expand Down Expand Up @@ -786,6 +786,16 @@ paths:
description: ID of a resource
example: 13079036966868018111
example: 8898227098768256088
- name: accessToken
in: cookie
description: Session ID
allowEmptyValue: true
required: true
schema:
type: string
description: Session ID
example: At a aliquam voluptates illo.
example: Illum et ut pariatur similique.
responses:
"200":
description: OK response.
Expand Down Expand Up @@ -835,14 +845,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 @@ -857,8 +859,18 @@ paths:
schema:
type: integer
description: ID of a resource
example: 17566308914815160138
example: 4705517885956809601
example: 5608341121233834653
example: 11617874741133432927
- name: accessToken
in: cookie
description: Session ID
allowEmptyValue: true
required: true
schema:
type: string
description: Session ID
example: Quia totam.
example: Reprehenderit maxime et velit itaque dolores dolor.
requestBody:
required: true
content:
Expand Down Expand Up @@ -910,14 +922,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
/resource/{id}/versions:
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.

Loading

0 comments on commit 8b442f8

Please sign in to comment.