Skip to content

Commit 21686e4

Browse files
authored
Allow anonymous token creation (#422)
Fixes #421
1 parent 4e3d196 commit 21686e4

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

api/v1/routes/onetimetokens.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77
*/
88

99
import { Router } from 'express'
10-
import * as auth from '../../../lib/auth.mjs'
1110

1211
import * as oneTimeTokensController from '../controllers/onetimetokens.mjs'
1312

1413
const router = Router({ mergeParams: true })
1514

16-
// Validation middleware
17-
router.use(/\/$/, auth.validateJWT)
18-
1915
router.post('/', oneTimeTokensController.create)
2016

2117
router.get('/:id', oneTimeTokensController.get)

docs/apidoc/paths/onetimetokens.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ get:
66
description: |
77
Get one time token content, encrypted with the key provided in the request. The token is then deleted and will not be accessible anymore.
88
The response will contain the initialization vector and the base64-encoded encrypted data in the form "iv:data". The key used for encryption is provided in the request.
9-
security:
10-
- bearerAuth: []
9+
You don't need to be authenticated to use this endpoint, but the token will be retreived only if you're the correct audience.
1110
parameters:
1211
- $ref: '..\parameters\onetimetokens.yaml#/token'
1312
- $ref: '..\parameters\onetimetokens.yaml#/key'
@@ -26,14 +25,12 @@ post:
2625
- One time tokens
2726
operationId: "createOneTimeToken"
2827
summary: Create a one time token
29-
description: Create a one time token
28+
description: Create a one time token; you don't need to be authenticated to use it.
3029
requestBody:
3130
content:
3231
application/json:
3332
schema:
3433
$ref: '..\requestbodies\onetimetokens.yaml#/oneTimeTokenCreateBody'
35-
security:
36-
- bearerAuth: []
3734
responses:
3835
"201":
3936
$ref: '..\responsebodies\default.yaml#/created'

docs/index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,17 @@ While groups can be nested to form a tree, there is no membership inheritance: i
120120

121121
### One time secrets
122122

123-
OTS are an easy way to share a secret with someone: you provide the data to share and you will receive back a unique token: accessing the token through the API, you will have access to the the decrypted data, **but only once**: once "consumed", the token will be deleted.
123+
OTS are an easy way to share a secret with someone: you provide the data to share and you will receive back a unique token: accessing the token through the API, you will have access to the the decrypted data, **but only once**: once "consumed", the token will be deleted. You can choose the audience of the OTS:
124+
- anyone (logged in or not)
125+
- anyone logged in (requires authentication for reading the token)
126+
- a specific user (both creator and reader must be authenticated)
124127

125128
This is similar to various public services you can find online.
126129

127130
You can share both random text, or an entire item.
128131

132+
Note that both creation and consumption of OTS don't require any authentication.
133+
129134
### API keys
130135

131136
API keys can be created to easier credential handling in case of automated clients. An API key is bound to a user, whose authentication method must be 'apikey': this way you can easily manage permissions as you would do for a regular

0 commit comments

Comments
 (0)