upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/98.md
diff options
context:
space:
mode:
Diffstat (limited to '98.md')
-rw-r--r--98.md14
1 files changed, 7 insertions, 7 deletions
diff --git a/98.md b/98.md
index ecbebc0..c8cba0f 100644
--- a/98.md
+++ b/98.md
@@ -6,9 +6,9 @@ HTTP Auth
6 6
7`draft` `optional` `author:kieran` `author:melvincarvalho` 7`draft` `optional` `author:kieran` `author:melvincarvalho`
8 8
9This NIP defines an ephemerial event used to authorize requests to HTTP servers using nostr events. 9This NIP defines an ephemeral event used to authorize requests to HTTP servers using nostr events.
10 10
11This is useful for HTTP services which are build for Nostr and deal with Nostr user accounts. 11This is useful for HTTP services which are built for Nostr and deal with Nostr user accounts.
12 12
13## Nostr event 13## Nostr event
14 14
@@ -16,7 +16,7 @@ A `kind 27235` (In reference to [RFC 7235](https://www.rfc-editor.org/rfc/rfc723
16 16
17The `content` SHOULD be empty. 17The `content` SHOULD be empty.
18 18
19The following tags are defined as REQUIRED. 19The following tags MUST be included.
20 20
21* `u` - absolute URL 21* `u` - absolute URL
22* `method` - HTTP Request Method 22* `method` - HTTP Request Method
@@ -45,7 +45,7 @@ Example event:
45 45
46Servers MUST perform the following checks in order to validate the event: 46Servers MUST perform the following checks in order to validate the event:
471. The `kind` MUST be `27235`. 471. The `kind` MUST be `27235`.
482. The `created_at` MUST be within a reasonable time window (suggestion 60 seconds). 482. The `created_at` timestamp MUST be within a reasonable time window (suggestion 60 seconds).
493. The `u` tag MUST be exactly the same as the absolute request URL (including query parameters). 493. The `u` tag MUST be exactly the same as the absolute request URL (including query parameters).
504. The `method` tag MUST be the same HTTP method used for the requested resource. 504. The `method` tag MUST be the same HTTP method used for the requested resource.
51 51
@@ -53,11 +53,11 @@ When the request contains a body (as in POST/PUT/PATCH methods) clients SHOULD i
53 53
54If one of the checks was to fail the server SHOULD respond with a 401 Unauthorized response code. 54If one of the checks was to fail the server SHOULD respond with a 401 Unauthorized response code.
55 55
56All other checks which server MAY do are OPTIONAL, and implementation specific. 56Servers MAY perform additional implementation-specific validation checks.
57 57
58## Request Flow 58## Request Flow
59 59
60Using the `Authorization` header, the `kind 27235` event MUST be `base64` encoded and use the Authorization scheme `Nostr` 60Using the `Authorization` HTTP header, the `kind 27235` event MUST be `base64` encoded and use the Authorization scheme `Nostr`
61 61
62Example HTTP Authorization header: 62Example HTTP Authorization header:
63``` 63```
@@ -65,4 +65,4 @@ Authorization: Nostr eyJpZCI6ImZlOTY0ZTc1ODkwMzM2MGYyOGQ4NDI0ZDA5MmRhODQ5NGVkMjA
65``` 65```
66 66
67## Reference Implementations 67## Reference Implementations
68- C# ASP.NET `AuthenticationHandler` [NostrAuth.cs](https://gist.github.com/v0l/74346ae530896115bfe2504c8cd018d3) \ No newline at end of file 68- C# ASP.NET `AuthenticationHandler` [NostrAuth.cs](https://gist.github.com/v0l/74346ae530896115bfe2504c8cd018d3)