Documentation
¶
Index ¶
- Constants
- func RandomString(n int) string
- type AES_GCM
- type CORSCapsule
- type CapsuleApp
- func (h *CapsuleApp) AddHandler(name string, handler func(w http.ResponseWriter, r *http.Request))
- func (c *CapsuleApp) AuthRequired(h http.Handler) http.Handler
- func (c *CapsuleApp) CORSRequired(h http.Handler) http.Handler
- func (c *CapsuleApp) DELETE(h http.Handler) http.Handler
- func (h *CapsuleApp) DefaultAuthenticationHandler(db Repository) func(w http.ResponseWriter, r *http.Request)
- func (h *CapsuleApp) DefaultHealthHandler(healthMessage ...string) func(w http.ResponseWriter, r *http.Request)
- func (c *CapsuleApp) GET(h http.Handler) http.Handler
- func (h *CapsuleApp) GetHandler(name string) func(w http.ResponseWriter, r *http.Request)
- func (c *CapsuleApp) OPTIONS(h http.Handler) http.Handler
- func (c *CapsuleApp) PATCH(h http.Handler) http.Handler
- func (c *CapsuleApp) POST(h http.Handler) http.Handler
- func (c *CapsuleApp) PUT(h http.Handler) http.Handler
- func (c *CapsuleApp) RegisterProtectedRoutes(routes []Route)
- func (c *CapsuleApp) RegisterRoutes(routes []Route)
- func (c *CapsuleApp) Run() error
- type CapsuleHandler
- type Claims
- type Handler
- type JSONResponse
- type JwtUser
- type Props
- type RSA_OAEP
- func (r *RSA_OAEP) DecryptOAEP(cipherText string, privKey *rsa.PrivateKey) (string, error)
- func (r *RSA_OAEP) EncryptOAEP(secretMessage string, key *rsa.PublicKey) (string, error)
- func (r *RSA_OAEP) GenerateRSAKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
- func (r *RSA_OAEP) GenerateRSAKeyPairAndSaveOnPath(bits int, path string)
- func (r *RSA_OAEP) LoadPrivateKey(path string) (*rsa.PrivateKey, error)
- func (r *RSA_OAEP) LoadPrivateKeyFromBytes(pemBytes []byte) (*rsa.PrivateKey, error)
- func (r *RSA_OAEP) LoadPublicKey(path string) (*rsa.PublicKey, error)
- func (r *RSA_OAEP) LoadPublicKeyFromBytes(pemBytes []byte) (*rsa.PublicKey, error)
- type Repository
- type Route
- type Router
- type SecurityCapsule
- type SecurityService
- type TokenPairs
- type User
Constants ¶
const PORT = 8080
Variables ¶
This section is empty.
Functions ¶
func RandomString ¶
RandomString returns a string of random characters of length n, using randomStringSource as the source for the string
Types ¶
type AES_GCM ¶
type AES_GCM struct{}
================================================================================================= AES GCM: Advanced Encryption Standard (AES) is a symmetric encryption algorithm. =================================================================================================
func (*AES_GCM) DecryptGCM ¶
func (*AES_GCM) EncryptGCM ¶
func (*AES_GCM) Generate32BytesBase64Key ¶
func (*AES_GCM) Generate32BytesKey ¶
type CORSCapsule ¶
type CapsuleApp ¶
type CapsuleApp struct {
PORT string
Security SecurityService
CORS CORSCapsule
Handlers []CapsuleHandler
Version string
}
func NewApp ¶
func NewApp(props ...Props) *CapsuleApp
func (*CapsuleApp) AddHandler ¶
func (h *CapsuleApp) AddHandler(name string, handler func(w http.ResponseWriter, r *http.Request))
func (*CapsuleApp) AuthRequired ¶
func (c *CapsuleApp) AuthRequired(h http.Handler) http.Handler
AUTH
func (*CapsuleApp) CORSRequired ¶
func (c *CapsuleApp) CORSRequired(h http.Handler) http.Handler
func (*CapsuleApp) DefaultAuthenticationHandler ¶
func (h *CapsuleApp) DefaultAuthenticationHandler(db Repository) func(w http.ResponseWriter, r *http.Request)
func (*CapsuleApp) DefaultHealthHandler ¶
func (h *CapsuleApp) DefaultHealthHandler(healthMessage ...string) func(w http.ResponseWriter, r *http.Request)
func (*CapsuleApp) GetHandler ¶
func (h *CapsuleApp) GetHandler(name string) func(w http.ResponseWriter, r *http.Request)
func (*CapsuleApp) RegisterProtectedRoutes ¶
func (c *CapsuleApp) RegisterProtectedRoutes(routes []Route)
func (*CapsuleApp) RegisterRoutes ¶
func (c *CapsuleApp) RegisterRoutes(routes []Route)
func (*CapsuleApp) Run ¶
func (c *CapsuleApp) Run() error
type CapsuleHandler ¶
type CapsuleHandler struct {
Name string
Handler func(w http.ResponseWriter, r *http.Request)
}
type Claims ¶
type Claims struct {
jwt.RegisteredClaims
}
type Handler ¶
type Handler struct {
Handlers []CapsuleHandler
}
type JSONResponse ¶
type JSONResponse struct {
Error bool `json:"error"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
func (JSONResponse) ErrorJson ¶
func (JSONResponse) ErrorJson(w http.ResponseWriter, err error, status ...int) error
func (JSONResponse) ReadJson ¶
func (JSONResponse) ReadJson(w http.ResponseWriter, r *http.Request, data interface{}) error
func (JSONResponse) WriteJSON ¶
func (JSONResponse) WriteJSON(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error
type Props ¶
type Props struct {
PORT uint
Security SecurityService
CORS CORSCapsule
Version string
}
type RSA_OAEP ¶
type RSA_OAEP struct{}
================================================================================================= RSA OAEP: RSA (Rivest-Shamir-Adleman) is an asymmetric encryption algorithm. =================================================================================================
func (*RSA_OAEP) DecryptOAEP ¶
func (*RSA_OAEP) EncryptOAEP ¶
OAEP is an asymmetric encryption algorithm that combines the RSA algorithm with the OAEP padding scheme. The RSA algorithm is used to encrypt the data, and the OAEP padding scheme is used to add randomness to the data.
func (*RSA_OAEP) GenerateRSAKeyPair ¶
func (*RSA_OAEP) GenerateRSAKeyPairAndSaveOnPath ¶
func (*RSA_OAEP) LoadPrivateKey ¶
func (r *RSA_OAEP) LoadPrivateKey(path string) (*rsa.PrivateKey, error)
func (*RSA_OAEP) LoadPrivateKeyFromBytes ¶
func (r *RSA_OAEP) LoadPrivateKeyFromBytes(pemBytes []byte) (*rsa.PrivateKey, error)
func (*RSA_OAEP) LoadPublicKey ¶
type Repository ¶
type SecurityCapsule ¶
type SecurityCapsule struct {
Issuer string
Audience string
Secret string
TokenExpiry time.Duration
RefreshExpiry time.Duration
CookieDomain string
CookiePath string
CookieName string
}
func (*SecurityCapsule) GenerateTokenPair ¶
func (s *SecurityCapsule) GenerateTokenPair(u *JwtUser) (*TokenPairs, error)
func (*SecurityCapsule) GetTokenFromHeaderAndVerify ¶
func (s *SecurityCapsule) GetTokenFromHeaderAndVerify(w http.ResponseWriter, r *http.Request) (string, *Claims, error)
type SecurityService ¶
type SecurityService interface {
GenerateTokenPair(u *JwtUser) (*TokenPairs, error)
GetTokenFromHeaderAndVerify(w http.ResponseWriter, r *http.Request) (string, *Claims, error)
}