alpha
Login
or
Join now
oyster.cafe
/
tangled-core
forked from
tangled.org/core
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Monorepo for Tangled
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
cmd/genjwks: add generate jwks script
author
Divya Jain
committer
Tangled
date
1 year ago
(May 13, 2025, 9:57 PM UTC)
commit
c1b5f8af
c1b5f8af08545deb46da789c376be2309fa40355
parent
f57bf86f
f57bf86f79a6935fee364d261d47e305e2af5d4e
+47
2 changed files
Expand all
Collapse all
Unified
Split
cmd
genjwks
main.go
scripts
generate-jwks.sh
+42
cmd/genjwks/main.go
Reviewed
···
1
1
+
// adapted from https://github.com/haileyok/atproto-oauth-golang
2
2
+
3
3
+
package main
4
4
+
5
5
+
import (
6
6
+
"crypto/ecdsa"
7
7
+
"crypto/elliptic"
8
8
+
"crypto/rand"
9
9
+
"encoding/json"
10
10
+
"fmt"
11
11
+
"os"
12
12
+
"time"
13
13
+
14
14
+
"github.com/lestrrat-go/jwx/v2/jwk"
15
15
+
)
16
16
+
17
17
+
func main() {
18
18
+
privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
19
19
+
if err != nil {
20
20
+
panic(err)
21
21
+
}
22
22
+
23
23
+
key, err := jwk.FromRaw(privKey)
24
24
+
if err != nil {
25
25
+
panic(err)
26
26
+
}
27
27
+
28
28
+
kid := fmt.Sprintf("%d", time.Now().Unix())
29
29
+
30
30
+
if err := key.Set(jwk.KeyIDKey, kid); err != nil {
31
31
+
panic(err)
32
32
+
}
33
33
+
34
34
+
b, err := json.Marshal(key)
35
35
+
if err != nil {
36
36
+
panic(err)
37
37
+
}
38
38
+
39
39
+
if err := os.WriteFile("./jwks.json", b, 0644); err != nil {
40
40
+
panic(err)
41
41
+
}
42
42
+
}
+5
scripts/generate-jwks.sh
Reviewed
···
1
1
+
#! /usr/bin/env bash
2
2
+
3
3
+
set -e
4
4
+
5
5
+
go run ./cmd/genjwks/