Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate JWK #84

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Generate JWK #84

wants to merge 4 commits into from

Conversation

mbilski
Copy link
Contributor

@mbilski mbilski commented Oct 10, 2023

#82

❯ go run . jwks generate -h
Generate JWK

Usage:
  oauth2c jwks generate [flags]

Flags:
      --curve int     curve (ec) (default 256)
  -h, --help          help for generate
      --size int      key size (rsa) (default 2048)
      --type string   key type (rsa, ps, ec) (default "rsa")
      --use string    key use (sig, enc) (default "sig")


❯ go run . jwks generate
                                                                                                                                                                      
                                                                             Generate JWK                                                                             
                                                                                                                                                                      

# Private JWK

{
  "use": "sig",
  "kty": "RSA",
  "kid": "2ac21f8e-81a7-43e8-b2ac-e031be0c15d8",
  "alg": "RS256",
  "n": "yIaAAtYgo1HH2wtk60QkQxuMgpX2LHB313lrJ0LQ47jbBcIAeZJLPhSRtdi2lXyCCwqSljP0556mx3bkGndd9OMl2jkGRkQUbN2zDxGEpSnSmqi_ZWvjXtdGV7kWjXwNs6clfYQW57xPRDH3P7vLXrDbGMWMDJDivvvNCiMEy170ihsC7y-WXljfJOPKz5aBoW2SSNz-ZAi4wCZ_qFfKxfTe_kuncnghIRl8j-TZnQHa6Kh7rFnjiOLxmaiHjMrF94R5BjsTjNJF70Q4sfwXuDjzniEWcJxjw9FdSXhNmZFpH4wiptJXDZvfjV8AkgeQRSBUzFuXYLUm9jRffhieVw",
  "e": "AQAB",
  "d": "U0q65XK3_966WxvygV6-iTlqNdvAc1kMDm6auaYhSlXAdDXPKLBBnLnChHxN6u3avmdX2BggxAy8TeHugafPWSb41BoXpxwkN8wm0j1-kXQ7zI4HYkNcIErfJxT0bzR2JIdrJSW2te8cJcFzZ__DS8O-Xh3APH_6D0ZcNrexCB_eUVqnXAegKdQOBs6_UOGyR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gpX2LHB313lrJ0LQ47jbBcIAeZJL
PhSRtdi2lXyCCwqSljP0556mx3bkGndd9OMl2jkGRkQUbN2zDxGEpSnSmqi/ZWvj
XtdGV7kWjXwNs6clfYQW57xPRDH3P7vLXrDbGMWMDJDivvvNCiMEy170ihsC7y+W
XljfJOPKz5aBoW2SSNz+ZAi4wCZ/qFfKxfTe/kuncnghIRl8j+TZnQHa6Kh7rFnj
iOLxmaiHjMrF94R5BjsTjNJF70Q4sfwXuDjzniEWcJxjw9FdSXhNmZFpH4wiptJX
DZvfjV8AkgeQRSBUzFuXYLUm9jRffhieVwIDAQAB
-----END RSA PUBLIC KEY-----

TODO

  • alg
  • docs
  • save to file --private-jwk-output private.json --public-jwk-output public.json. --private-key-output private.pem --public-key-output public.pem --cert-output cert.pem

@mbilski mbilski requested a review from ikawalec October 10, 2023 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant