types.go 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // Only set after successfully completing acme device-attest-01 challenge
  65. AttestationData *AttestationData `json:"attestationData,omitempty"`
  66. // Set for most provisioners, but not acme or scep
  67. // Token any `json:"token,omitempty"`
  68. // Exactly one of the remaining fields should be set
  69. X509CertificateRequest *X509CertificateRequest `json:"x509CertificateRequest,omitempty"`
  70. X509Certificate *X509Certificate `json:"x509Certificate,omitempty"`
  71. SSHCertificateRequest *SSHCertificateRequest `json:"sshCertificateRequest,omitempty"`
  72. SSHCertificate *SSHCertificate `json:"sshCertificate,omitempty"`
  73. // Only set for SCEP webhook requests
  74. SCEPChallenge string `json:"scepChallenge,omitempty"`
  75. SCEPTransactionID string `json:"scepTransactionID,omitempty"`
  76. SCEPErrorCode int `json:"scepErrorCode,omitempty"`
  77. SCEPErrorDescription string `json:"scepErrorDescription,omitempty"`
  78. // Only set for X5C provisioners
  79. X5CCertificate *X5CCertificate `json:"x5cCertificate,omitempty"`
  80. // Set for X5C, AWS, GCP, and Azure provisioners
  81. AuthorizationPrincipal string `json:"authorizationPrincipal,omitempty"`
  82. }