Skip to content

Commit 3b3f5ec

Browse files
author
SM43
committed
Adds expiry time in User access JWT and auth also returns Refresh JWT
This adds expiry time in user jwt and auth returns refresh jwt along with access jwt. The refresh jwt can be later used to get a new access jwt. Signed-off-by: Shivam Mukhade <smukhade@redhat.com>
1 parent f56d79d commit 3b3f5ec

27 files changed

+535
-201
lines changed

api/.env.dev

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ POSTGRES_PASSWORD="postgres"
88

99
GH_CLIENT_ID=""
1010
GH_CLIENT_SECRET=""
11-
JWT_SIGNING_KEY=""
11+
12+
ACCESS_JWT_SIGNING_KEY=""
13+
REFRESH_JWT_SIGNING_KEY=""
14+
ACCESS_JWT_EXPIRES_IN=""
15+
REFRESH_JWT_EXPIRES_IN=""
1216

1317
CONFIG_FILE_URL="file://../config.yaml"

api/design/auth.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ var _ = Service("auth", func() {
3535
Required("code")
3636
})
3737
Result(func() {
38-
Attribute("token", String, "JSON Web Token with user details", func() {
39-
Example("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."+
40-
"eyJpZCI6MTAwMDEsImxvZ2luIjoidGVzdCIsIm5hbWUiOiJ0ZXN0LXVzZXIiLCJzY29wZXMiOlsicmF0aW5nOnJlYWQiLCJyYXRpbmc6d3JpdGUiXX0."+
41-
"zFztueyvZLLCyx3RD7WpzzfVaTrybzxgS5a_pDsq5M8")
38+
Attribute("accessToken", String, "User Access JWT", func() {
39+
Example("accessToken", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."+
40+
"eyJleHAiOjE1Nzc5NjY0MDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJhdGluZzpyZWFkIiwicmF0aW5nOndyaXRlIiwiYWdlbnQ6Y3JlYXRlIl0sInR5cGUiOiJhY2Nlc3MtdG9rZW4ifQ."+
41+
"ESWCc5fi2B5bOzodAznnlKtDqtg-HeARnC3RN5hU8l0")
4242
})
43-
Required("token")
43+
Attribute("refreshToken", String, "User Refresh JWT", func() {
44+
Example("refreshToken", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."+
45+
"eyJleHAiOjE1Nzc4ODAzMDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJlZnJlc2g6dG9rZW4iXSwidHlwZSI6InJlZnJlc2gtdG9rZW4ifQ."+
46+
"LRMeNIcg-M7GO44FGiZexpf7nMsGMTsE6Ykx9rt3y5I")
47+
})
48+
Required("accessToken", "refreshToken")
4449
})
4550

4651
HTTP(func() {

api/gen/auth/service.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/http/auth/client/types.go

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/http/auth/server/types.go

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/http/openapi.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

api/gen/http/openapi.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ paths:
4646
schema:
4747
$ref: '#/definitions/AuthAuthenticateResponseBody'
4848
required:
49-
- token
49+
- accessToken
50+
- refreshToken
5051
"400":
5152
description: Bad Request response.
5253
schema:
@@ -1130,14 +1131,20 @@ definitions:
11301131
title: AuthAuthenticateResponseBody
11311132
type: object
11321133
properties:
1133-
token:
1134+
accessToken:
11341135
type: string
1135-
description: JSON Web Token with user details
1136-
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAwMDEsImxvZ2luIjoidGVzdCIsIm5hbWUiOiJ0ZXN0LXVzZXIiLCJzY29wZXMiOlsicmF0aW5nOnJlYWQiLCJyYXRpbmc6d3JpdGUiXX0.zFztueyvZLLCyx3RD7WpzzfVaTrybzxgS5a_pDsq5M8
1136+
description: User Access JWT
1137+
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc5NjY0MDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJhdGluZzpyZWFkIiwicmF0aW5nOndyaXRlIiwiYWdlbnQ6Y3JlYXRlIl0sInR5cGUiOiJhY2Nlc3MtdG9rZW4ifQ.ESWCc5fi2B5bOzodAznnlKtDqtg-HeARnC3RN5hU8l0
1138+
refreshToken:
1139+
type: string
1140+
description: User Refresh JWT
1141+
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc4ODAzMDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJlZnJlc2g6dG9rZW4iXSwidHlwZSI6InJlZnJlc2gtdG9rZW4ifQ.LRMeNIcg-M7GO44FGiZexpf7nMsGMTsE6Ykx9rt3y5I
11371142
example:
1138-
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAwMDEsImxvZ2luIjoidGVzdCIsIm5hbWUiOiJ0ZXN0LXVzZXIiLCJzY29wZXMiOlsicmF0aW5nOnJlYWQiLCJyYXRpbmc6d3JpdGUiXX0.zFztueyvZLLCyx3RD7WpzzfVaTrybzxgS5a_pDsq5M8
1143+
accessToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc5NjY0MDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJhdGluZzpyZWFkIiwicmF0aW5nOndyaXRlIiwiYWdlbnQ6Y3JlYXRlIl0sInR5cGUiOiJhY2Nlc3MtdG9rZW4ifQ.ESWCc5fi2B5bOzodAznnlKtDqtg-HeARnC3RN5hU8l0
1144+
refreshToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc4ODAzMDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJlZnJlc2g6dG9rZW4iXSwidHlwZSI6InJlZnJlc2gtdG9rZW4ifQ.LRMeNIcg-M7GO44FGiZexpf7nMsGMTsE6Ykx9rt3y5I
11391145
required:
1140-
- token
1146+
- accessToken
1147+
- refreshToken
11411148
CatalogRefreshInternalErrorResponseBody:
11421149
title: 'Mediatype identifier: application/vnd.goa.error; view=default'
11431150
type: object

api/gen/http/openapi3.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

api/gen/http/openapi3.yaml

Lines changed: 45 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ paths:
5757
schema:
5858
$ref: '#/components/schemas/AuthenticateResponseBody'
5959
example:
60-
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAwMDEsImxvZ2luIjoidGVzdCIsIm5hbWUiOiJ0ZXN0LXVzZXIiLCJzY29wZXMiOlsicmF0aW5nOnJlYWQiLCJyYXRpbmc6d3JpdGUiXX0.zFztueyvZLLCyx3RD7WpzzfVaTrybzxgS5a_pDsq5M8
60+
accessToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc5NjY0MDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJhdGluZzpyZWFkIiwicmF0aW5nOndyaXRlIiwiYWdlbnQ6Y3JlYXRlIl0sInR5cGUiOiJhY2Nlc3MtdG9rZW4ifQ.ESWCc5fi2B5bOzodAznnlKtDqtg-HeARnC3RN5hU8l0
61+
refreshToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc4ODAzMDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJlZnJlc2g6dG9rZW4iXSwidHlwZSI6InJlZnJlc2gtdG9rZW4ifQ.LRMeNIcg-M7GO44FGiZexpf7nMsGMTsE6Ykx9rt3y5I
6162
"400":
6263
description: ""
6364
content:
@@ -229,7 +230,7 @@ paths:
229230
type: array
230231
items:
231232
type: string
232-
example: Ducimus ab natus autem.
233+
example: Placeat et et.
233234
description: Kinds of resource to filter by
234235
example:
235236
- task
@@ -245,7 +246,7 @@ paths:
245246
type: array
246247
items:
247248
type: string
248-
example: Id porro placeat et et at itaque.
249+
example: Itaque aperiam tempore animi iure eum et.
249250
description: Tags associated with a resource to filter by
250251
example:
251252
- image
@@ -521,7 +522,7 @@ paths:
521522
enum:
522523
- task
523524
- pipeline
524-
example: task
525+
example: pipeline
525526
- name: name
526527
in: path
527528
description: name of resource
@@ -685,8 +686,8 @@ paths:
685686
schema:
686687
type: integer
687688
description: ID of a resource
688-
example: 5784126447885838359
689-
example: 11631482911919877445
689+
example: 11620657542064230955
690+
example: 11665674017405905075
690691
responses:
691692
"200":
692693
description: ""
@@ -769,8 +770,8 @@ paths:
769770
schema:
770771
type: integer
771772
description: ID of a resource
772-
example: 8451480480088601963
773-
example: 10151677062152764094
773+
example: 4869966896348576719
774+
example: 6109420220413662287
774775
requestBody:
775776
required: true
776777
content:
@@ -1198,7 +1199,7 @@ paths:
11981199
content:
11991200
application/json:
12001201
schema:
1201-
$ref: '#/components/schemas/AuthenticateResponseBody'
1202+
$ref: '#/components/schemas/UpdateAgentResponseBody'
12021203
example:
12031204
token: Nobis est voluptatibus numquam rerum.
12041205
"400":
@@ -1265,14 +1266,20 @@ components:
12651266
AuthenticateResponseBody:
12661267
type: object
12671268
properties:
1268-
token:
1269+
accessToken:
12691270
type: string
1270-
description: JSON Web Token with user details
1271-
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAwMDEsImxvZ2luIjoidGVzdCIsIm5hbWUiOiJ0ZXN0LXVzZXIiLCJzY29wZXMiOlsicmF0aW5nOnJlYWQiLCJyYXRpbmc6d3JpdGUiXX0.zFztueyvZLLCyx3RD7WpzzfVaTrybzxgS5a_pDsq5M8
1271+
description: User Access JWT
1272+
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc5NjY0MDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJhdGluZzpyZWFkIiwicmF0aW5nOndyaXRlIiwiYWdlbnQ6Y3JlYXRlIl0sInR5cGUiOiJhY2Nlc3MtdG9rZW4ifQ.ESWCc5fi2B5bOzodAznnlKtDqtg-HeARnC3RN5hU8l0
1273+
refreshToken:
1274+
type: string
1275+
description: User Refresh JWT
1276+
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc4ODAzMDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJlZnJlc2g6dG9rZW4iXSwidHlwZSI6InJlZnJlc2gtdG9rZW4ifQ.LRMeNIcg-M7GO44FGiZexpf7nMsGMTsE6Ykx9rt3y5I
12721277
example:
1273-
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAwMDEsImxvZ2luIjoidGVzdCIsIm5hbWUiOiJ0ZXN0LXVzZXIiLCJzY29wZXMiOlsicmF0aW5nOnJlYWQiLCJyYXRpbmc6d3JpdGUiXX0.zFztueyvZLLCyx3RD7WpzzfVaTrybzxgS5a_pDsq5M8
1278+
accessToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc5NjY0MDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJhdGluZzpyZWFkIiwicmF0aW5nOndyaXRlIiwiYWdlbnQ6Y3JlYXRlIl0sInR5cGUiOiJhY2Nlc3MtdG9rZW4ifQ.ESWCc5fi2B5bOzodAznnlKtDqtg-HeARnC3RN5hU8l0
1279+
refreshToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Nzc4ODAzMDAsImlhdCI6MTU3Nzg4MDAwMCwiaWQiOjExLCJpc3MiOiJUZWt0b24gSHViIiwibG9naW4iOiJmb28iLCJuYW1lIjoiZm9vIiwic2NvcGVzIjpbInJlZnJlc2g6dG9rZW4iXSwidHlwZSI6InJlZnJlc2gtdG9rZW4ifQ.LRMeNIcg-M7GO44FGiZexpf7nMsGMTsE6Ykx9rt3y5I
12741280
required:
1275-
- token
1281+
- accessToken
1282+
- refreshToken
12761283
Catalog:
12771284
type: object
12781285
properties:
@@ -1418,14 +1425,14 @@ components:
14181425
id:
14191426
type: integer
14201427
description: id of the job
1421-
example: 2047971223909365425
1428+
example: 1775143685620788290
14221429
status:
14231430
type: string
14241431
description: status of the job
1425-
example: Omnis qui aut.
1432+
example: Dolorum sapiente.
14261433
example:
1427-
id: 11929803235502470516
1428-
status: Animi molestiae nam quas veniam optio accusamus.
1434+
id: 8451480480088601963
1435+
status: Vitae ducimus.
14291436
required:
14301437
- id
14311438
- status
@@ -1494,9 +1501,9 @@ components:
14941501
force:
14951502
type: boolean
14961503
description: Force Refresh the config file
1497-
example: false
1504+
example: true
14981505
example:
1499-
force: true
1506+
force: false
15001507
required:
15011508
- force
15021509
RefreshConfigResponseBody:
@@ -1505,9 +1512,9 @@ components:
15051512
checksum:
15061513
type: string
15071514
description: Config file checksum
1508-
example: Mollitia dolorem laudantium.
1515+
example: Sint omnis consequatur.
15091516
example:
1510-
checksum: Amet suscipit fuga nam.
1517+
checksum: Qui aut sed voluptas animi molestiae.
15111518
required:
15121519
- checksum
15131520
Resource:
@@ -1673,54 +1680,6 @@ components:
16731680
version: "0.1"
16741681
- id: 2
16751682
version: "0.2"
1676-
- catalog:
1677-
id: 1
1678-
type: community
1679-
id: 1
1680-
kind: task
1681-
latestVersion:
1682-
description: Buildah task builds source into a container image and then pushes it to a container registry.
1683-
displayName: Buildah
1684-
id: 1
1685-
minPipelinesVersion: 0.12.1
1686-
rawURL: https://raw.githubusercontent.com/tektoncd/catalog/master/task/buildah/0.1/buildah.yaml
1687-
updatedAt: 2020-01-01 12:00:00 +0000 UTC
1688-
version: "0.1"
1689-
webURL: https://github.com/tektoncd/catalog/blob/master/task/buildah/0.1/buildah.yaml
1690-
name: buildah
1691-
rating: 4.3
1692-
tags:
1693-
- id: 1
1694-
name: image-build
1695-
versions:
1696-
- id: 1
1697-
version: "0.1"
1698-
- id: 2
1699-
version: "0.2"
1700-
- catalog:
1701-
id: 1
1702-
type: community
1703-
id: 1
1704-
kind: task
1705-
latestVersion:
1706-
description: Buildah task builds source into a container image and then pushes it to a container registry.
1707-
displayName: Buildah
1708-
id: 1
1709-
minPipelinesVersion: 0.12.1
1710-
rawURL: https://raw.githubusercontent.com/tektoncd/catalog/master/task/buildah/0.1/buildah.yaml
1711-
updatedAt: 2020-01-01 12:00:00 +0000 UTC
1712-
version: "0.1"
1713-
webURL: https://github.com/tektoncd/catalog/blob/master/task/buildah/0.1/buildah.yaml
1714-
name: buildah
1715-
rating: 4.3
1716-
tags:
1717-
- id: 1
1718-
name: image-build
1719-
versions:
1720-
- id: 1
1721-
version: "0.1"
1722-
- id: 2
1723-
version: "0.2"
17241683
ResourceVersion:
17251684
type: object
17261685
properties:
@@ -1953,6 +1912,9 @@ components:
19531912
- error: unable to reach db
19541913
name: api
19551914
status: ok
1915+
- error: unable to reach db
1916+
name: api
1917+
status: ok
19561918
Tag:
19571919
type: object
19581920
properties:
@@ -1995,17 +1957,28 @@ components:
19951957
required:
19961958
- name
19971959
- scopes
1960+
UpdateAgentResponseBody:
1961+
type: object
1962+
properties:
1963+
token:
1964+
type: string
1965+
description: Agent JWT
1966+
example: Sequi officiis mollitia.
1967+
example:
1968+
token: Laudantium quidem amet suscipit fuga nam.
1969+
required:
1970+
- token
19981971
UpdateRequestBody:
19991972
type: object
20001973
properties:
20011974
rating:
20021975
type: integer
20031976
description: User rating for resource
2004-
example: 1
1977+
example: 2
20051978
minimum: 0
20061979
maximum: 5
20071980
example:
2008-
rating: 0
1981+
rating: 4
20091982
required:
20101983
- rating
20111984
Versions:

0 commit comments

Comments
 (0)