Documentation ¶
Index ¶
- func DecodeRSAPrivateKey(data []byte) (*rsa.PrivateKey, error)
- func DecodeRSAPublicKey(data []byte) (*rsa.PublicKey, error)
- func ExtractBearerToken(r *http.Request) (string, error)
- func GenerateSHA256(s string) string
- func GenerateSHA256NoPadding(s string) string
- func GetAuthenticatedUserFromContext(ctx context.Context) (string, bool)
- func LoadRSAKeyFromFile(privateKeyPath, publicKeyPath string) (*rsa.PrivateKey, error)
- func LoadRSAPrivateKeyFromFile(path string) (*rsa.PrivateKey, error)
- func LoadRSAPublicKeyFromFile(path string) (*rsa.PublicKey, error)
- func RandString(length int) string
- func RandStringWithCharset(length int, charset string) string
- func SetAuthenticatedUserInContext(ctx context.Context, userID string) context.Context
- func ValidateStruct(v interface{}) error
- type MissingAuthenticationToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeRSAPrivateKey ¶
func DecodeRSAPrivateKey(data []byte) (*rsa.PrivateKey, error)
DecodeRSAPrivateKey decodes a PEM PKCS1 private key into a rsa.PrivateKey. NOTE: Public Key is automatically derived from the private key.
func DecodeRSAPublicKey ¶
DecodeRSAPublicKey decodes a PEM PKCS1 public key into a rsa.PublicKey.
func ExtractBearerToken ¶
ExtractBearerToken obtains the authentication token from a request using the "Bearer" authorization scheme. 'Authorization: Bearer {token}'
func GenerateSHA256 ¶
GenerateSHA256 generates the Base64 URL Encoded SHA-256 hash of a given string.
func GenerateSHA256NoPadding ¶
GenerateSHA256NoPadding generates the Base64 URL Encoded SHA-256 hash of a given string with no padding.
func GetAuthenticatedUserFromContext ¶
GetAuthenticatedUserFromContext retrieves the nickname of the user who performs the operation from the context.
func LoadRSAKeyFromFile ¶
func LoadRSAKeyFromFile(privateKeyPath, publicKeyPath string) (*rsa.PrivateKey, error)
LoadRSAKeyFromFile reads a PEM PKCS1 key pair (private and public key) into a rsa.PrivateKey with the PublicKey properly set to the given one, instead of the default deriving from the private key.
func LoadRSAPrivateKeyFromFile ¶
func LoadRSAPrivateKeyFromFile(path string) (*rsa.PrivateKey, error)
LoadRSAPrivateKeyFromFile reads a PEM PKCS1 private key file into a rsa.PrivateKey. NOTE: Public Key is automatically derived from the private key.
func LoadRSAPublicKeyFromFile ¶
LoadRSAPublicKeyFromFile reads a PEM PKCS1 public key file into a rsa.PublicKey.
func RandString ¶
RandString generates a random string of the given length using alphanumeric characters.
func RandStringWithCharset ¶
RandStringWithCharset generates a random string of the given length using characters in the given charset.
func SetAuthenticatedUserInContext ¶
SetAuthenticatedUserInContext stores the userID of the user who performs a operation in the context.
func ValidateStruct ¶
func ValidateStruct(v interface{}) error
ValidateStruct validates the given struct based on the struct tags added to the fields. If some field of the struct doesn't fulfill the validation requirements an error is returned.
Types ¶
type MissingAuthenticationToken ¶
type MissingAuthenticationToken struct{}
MissingAuthenticationToken is the error returned when an authentication token is not properly present in the HTTP request.
func (*MissingAuthenticationToken) Error ¶
func (e *MissingAuthenticationToken) Error() string