Secret REST service using OpenPGP.js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

package SecREST
import (
"net/http"
"time"
)
// SecRESTRequest is a decrypted request coming in from a client
type SecRESTRequest struct {
Path string `json:"Path"`
Body string `json:"Body"`
ClientIdentifier string `json:"ClientIdentifier"`
Insecure bool
TimeStamp time.Time `json:"TimeStamp"`
AuthRequest SecRESTAuthRequest `json:"AuthRequest"`
}
// SecRESTResponse is a decrypted response to be sent to the client
// Will be encrypted if request.Insecure = false
type SecRESTResponse struct {
Status int `json:"Status"`
Body string `json:"Body"`
Ellapsed string `json:"Ellapsed"`
AuthResponse SecRESTAuthResponse `json:"AuthResponse"`
}
// Struct for handlers, Insecure = True allows /insecure access
type SecRESTHandler struct {
Path string
Insecure bool
Body string
Run func(SecRESTRequest) SecRESTResponse
}
// SecRESTAuth struct is for authenticating a client, and storing their PGP key
type SecRESTAuth struct {
// Handle Authentication for new client
Run func(w http.ResponseWriter, r *http.Request) (bool, SecRESTAuthRequest)
}
type SecRESTAuthResponse struct {
ServerKey string `json:"ServerKey"`
ClientIdentifier string `json:"ClientIdentifier"`
}
type SecRESTAuthRequest struct {
ClientKey string `json:"ClientKey"`
}