types.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package webhook
  2. import (
  3. "time"
  4. "go.step.sm/crypto/sshutil"
  5. "go.step.sm/crypto/x509util"
  6. )
  7. // ResponseBody is the body returned by webhook servers.
  8. type ResponseBody struct {
  9. Data any `json:"data"`
  10. Allow bool `json:"allow"`
  11. }
  12. // X509CertificateRequest is the certificate request sent to webhook servers for
  13. // enriching webhooks when signing x509 certificates
  14. type X509CertificateRequest struct {
  15. *x509util.CertificateRequest
  16. PublicKey []byte `json:"publicKey"`
  17. PublicKeyAlgorithm string `json:"publicKeyAlgorithm"`
  18. Raw []byte `json:"raw"`
  19. }
  20. // X509Certificate is the certificate sent to webhook servers for authorizing
  21. // webhooks when signing x509 certificates
  22. type X509Certificate struct {
  23. *x509util.Certificate
  24. PublicKey []byte `json:"publicKey"`
  25. PublicKeyAlgorithm string `json:"publicKeyAlgorithm"`
  26. NotBefore time.Time `json:"notBefore"`
  27. NotAfter time.Time `json:"notAfter"`
  28. }
  29. // SSHCertificateRequest is the certificate request sent to webhook servers for
  30. // enriching webhooks when signing SSH certificates
  31. type SSHCertificateRequest struct {
  32. PublicKey []byte `json:"publicKey"`
  33. Type string `json:"type"`
  34. KeyID string `json:"keyID"`
  35. Principals []string `json:"principals"`
  36. }
  37. // SSHCertificate is the certificate sent to webhook servers for authorizing
  38. // webhooks when signing SSH certificates
  39. type SSHCertificate struct {
  40. *sshutil.Certificate
  41. PublicKey []byte `json:"publicKey"`
  42. SignatureKey []byte `json:"signatureKey"`
  43. ValidBefore uint64 `json:"validBefore"`
  44. ValidAfter uint64 `json:"validAfter"`
  45. }
  46. // AttestationData is data validated by acme device-attest-01 challenge
  47. type AttestationData struct {
  48. PermanentIdentifier string `json:"permanentIdentifier"`
  49. }
  50. // RequestBody is the body sent to webhook servers.
  51. type RequestBody struct {
  52. Timestamp time.Time `json:"timestamp"`
  53. // Only set after successfully completing acme device-attest-01 challenge
  54. AttestationData *AttestationData `json:"attestationData,omitempty"`
  55. // Set for most provisioners, but not acme or scep
  56. // Token any `json:"token,omitempty"`
  57. // Exactly one of the remaining fields should be set
  58. X509CertificateRequest *X509CertificateRequest `json:"x509CertificateRequest,omitempty"`
  59. X509Certificate *X509Certificate `json:"x509Certificate,omitempty"`
  60. SSHCertificateRequest *SSHCertificateRequest `json:"sshCertificateRequest,omitempty"`
  61. SSHCertificate *SSHCertificate `json:"sshCertificate,omitempty"`
  62. }