Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptPayloadFromContext ¶
retrieves token from gin context
Types ¶
type AuthCrypt ¶
type AuthCrypt interface { // indicates if crypt instance has been // initialized with authenticated keys // that are synchronized between the // client and server IsAuthenticated() bool WaitForAuth() bool // a key to be passed along with encrypted // auth tokens and used to verify the // authenticity of requests AuthTokenKey() string // crypt instance used to encrypt and // decrypt tokens and payloads. the // cipher can change when auth keys // are recycled so the mutex should // be used to guard access to it Crypt() (*crypto.Crypt, *sync.Mutex) }
specification for an authenticatable and encryptedable rest api interface used to secure requests
type AuthToken ¶
type AuthToken interface { // updates with an encrypted token SetEncryptedToken(encryptedToken string) error // returns the encrypted auth token GetEncryptedToken() (string, error) // signs the data for the given keys in the transport // data request headers and "body" for a request and // response headers and "body" for a response. data // would point to either an http.Request or http.Response // instance. SignTransportData(keys []string, data interface{}) error ValidateTransportData(data interface{}) error // signs and encrypts the given payload EncryptPayload(payload io.Reader) (io.Reader, error) // decrypts the payload and validates the decrypted // payload checksum DecryptPayload(body io.Reader) (io.ReadCloser, error) DecryptAndDecodePayload(body io.Reader, obj interface{}) error // saves the token in the gin context SetInContext(c *gin.Context) }
func NewRequestAuthToken ¶
creates an authenticated token to send with a request
func NewResponseAuthToken ¶
creates and authenticated response token from a request token
type RenderEncryptedPayload ¶
type RenderEncryptedPayload struct {
// contains filtered or unexported fields
}
Gin renderer for encrypted payloads
func NewEncryptedRender ¶
func NewEncryptedRender(c *gin.Context, p interface{}) RenderEncryptedPayload
func (RenderEncryptedPayload) Render ¶
func (r RenderEncryptedPayload) Render(w http.ResponseWriter) error
func (RenderEncryptedPayload) WriteContentType ¶
func (r RenderEncryptedPayload) WriteContentType(w http.ResponseWriter)
type Request ¶
type RestApiClient ¶
type RestApiClient struct {
// contains filtered or unexported fields
}
func NewRestApiClient ¶
func NewRestApiClient(ctx context.Context, url string) *RestApiClient
func (*RestApiClient) NewRequest ¶
func (c *RestApiClient) NewRequest(request *Request) *Request
func (*RestApiClient) WithAuthCrypt ¶
func (c *RestApiClient) WithAuthCrypt(authCrypt AuthCrypt) *RestApiClient
func (*RestApiClient) WithHttpClient ¶
func (c *RestApiClient) WithHttpClient(httpClient *http.Client) *RestApiClient
Click to show internal directories.
Click to hide internal directories.