types.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. Raw []byte `json:"raw"`
  29. }
  30. // SSHCertificateRequest is the certificate request sent to webhook servers for
  31. // enriching webhooks when signing SSH certificates
  32. type SSHCertificateRequest struct {
  33. PublicKey []byte `json:"publicKey"`
  34. Type string `json:"type"`
  35. KeyID string `json:"keyID"`
  36. Principals []string `json:"principals"`
  37. }
  38. // SSHCertificate is the certificate sent to webhook servers for authorizing
  39. // webhooks when signing SSH certificates
  40. type SSHCertificate struct {
  41. *sshutil.Certificate
  42. PublicKey []byte `json:"publicKey"`
  43. SignatureKey []byte `json:"signatureKey"`
  44. ValidBefore uint64 `json:"validBefore"`
  45. ValidAfter uint64 `json:"validAfter"`
  46. }
  47. // AttestationData is data validated by acme device-attest-01 challenge
  48. type AttestationData struct {
  49. PermanentIdentifier string `json:"permanentIdentifier"`
  50. }
  51. // X5CCertificate is the authorization certificate sent to webhook servers for
  52. // enriching or authorizing webhooks when signing X509 or SSH certificates using
  53. // the X5C provisioner.
  54. type X5CCertificate struct {
  55. Raw []byte `json:"raw"`
  56. PublicKey []byte `json:"publicKey"`
  57. PublicKeyAlgorithm string `json:"publicKeyAlgorithm"`
  58. NotBefore time.Time `json:"notBefore"`
  59. NotAfter time.Time `json:"notAfter"`
  60. }
  61. // RequestBody is the body sent to webhook servers.
  62. type RequestBody struct {
  63. Timestamp time.Time `json:"timestamp"`
  64. ProvisionerName string `json:"provisionerName,omitempty"`
  65. // Only set after successfully completing acme device-attest-01 challenge
  66. AttestationData *AttestationData `json:"attestationData,omitempty"`
  67. // Set for most provisioners, but not acme or scep
  68. // Token any `json:"token,omitempty"`
  69. // Exactly one of the remaining fields should be set
  70. X509CertificateRequest *X509CertificateRequest `json:"x509CertificateRequest,omitempty"`
  71. X509Certificate *X509Certificate `json:"x509Certificate,omitempty"`
  72. SSHCertificateRequest *SSHCertificateRequest `json:"sshCertificateRequest,omitempty"`
  73. SSHCertificate *SSHCertificate `json:"sshCertificate,omitempty"`
  74. // Only set for SCEP webhook requests
  75. SCEPChallenge string `json:"scepChallenge,omitempty"`
  76. SCEPTransactionID string `json:"scepTransactionID,omitempty"`
  77. SCEPErrorCode int `json:"scepErrorCode,omitempty"`
  78. SCEPErrorDescription string `json:"scepErrorDescription,omitempty"`
  79. // Only set for X5C provisioners
  80. X5CCertificate *X5CCertificate `json:"x5cCertificate,omitempty"`
  81. // Set for X5C, AWS, GCP, and Azure provisioners
  82. AuthorizationPrincipal string `json:"authorizationPrincipal,omitempty"`
  83. }