Documentation ¶
Index ¶
- Constants
- Variables
- func BodyParser(c *fiber.Ctx, data interface{}) error
- func ConnectionToken(account uuid.UUID, session string, extra string, node uint) (string, error)
- func DebugRouteError(c *fiber.Ctx, msg localization.Translations)
- func DecryptAES(key, ciphertext []byte) ([]byte, error)
- func DecryptRSA(privateKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
- func EncryptAES(key, plaintext []byte) ([]byte, error)
- func EncryptRSA(publicKey *rsa.PublicKey, message []byte) ([]byte, error)
- func FailedRequest(c *fiber.Ctx, message localization.Translations, err error) error
- func GenerateRSAKey(keySize int) (*rsa.PrivateKey, *rsa.PublicKey, error)
- func GetSystemUUID() uuid.UUID
- func InvalidRequest(c *fiber.Ctx) error
- func IsExpired(c *fiber.Ctx) bool
- func NewAESKey() ([]byte, error)
- func PackageRSAPrivateKey(privateKey *rsa.PrivateKey) string
- func PackageRSAPublicKey(publicKey *rsa.PublicKey) string
- func PostRequest(key *rsa.PublicKey, url string, body map[string]interface{}) (map[string]interface{}, error)
- func PostRequestNoTC(url string, body map[string]interface{}) (map[string]interface{}, error)
- func ReturnJSON(c *fiber.Ctx, data interface{}) error
- func SignRSA(privateKey *rsa.PrivateKey, message string) (string, error)
- func SuccessfulRequest(c *fiber.Ctx) error
- func TestAES()
- func Token(session uuid.UUID, account uuid.UUID, lvl uint, exp time.Time) (string, error)
- func UnpackageRSAPrivateKey(priv string) (*rsa.PrivateKey, error)
- func UnpackageRSAPublicKey(pub string) (*rsa.PublicKey, error)
- func VerifyRSASignature(signature string, publicKey *rsa.PublicKey, message string) error
- type ConnectionTokenClaims
Constants ¶
const CodeInvalid = "code.invalid"
const EmailInvalid = "email.invalid"
Auth errors
const EmailRegistered = "email.registered" // When it is already registered
const EnvAppName = "APP_NAME" // Configure the app name
Environment variables
const InviteInvalid = "invite.invalid"
const LocalsBody = "body"
const LocalsKey = "key"
const LocalsServerPriv = "srv_priv"
Locals constants
const LocalsServerPub = "srv_pub"
const PasswordInvalid = "password.incorrect"
const ProtocolVersion = 7
Important variables
const StandardKeySize = 2048
const TagInvalid = "tag.invalid"
const UsernameInvalid = "username.invalid"
const UsernameTaken = "username.taken"
Variables ¶
var JWT_SECRET = ""
var LogErrors = true
var NodeProtocol = "http://"
var Testing = false
Functions ¶
func ConnectionToken ¶
Generate a connection token for a node
func DebugRouteError ¶
func DebugRouteError(c *fiber.Ctx, msg localization.Translations)
func DecryptAES ¶
Decrypt decrypts the given ciphertext using AES-GCM.
func DecryptRSA ¶
func DecryptRSA(privateKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
Decrypt a message with a private key. (can't be infinitely long)
func EncryptAES ¶
Encrypt encrypts the given plaintext using AES-GCM.
func EncryptRSA ¶
Encrypt a message with a public key. (can't be infinitely long)
func FailedRequest ¶
func FailedRequest(c *fiber.Ctx, message localization.Translations, err error) error
func GenerateRSAKey ¶
Generate a new RSA key pair.
func GetSystemUUID ¶
Get the system uuid set in the environment variables
func InvalidRequest ¶
func InvalidRequest(c *fiber.Ctx) error
func PackageRSAPrivateKey ¶
func PackageRSAPrivateKey(privateKey *rsa.PrivateKey) string
PackageRSAPrivateKey packages a private key into our own format. Packaging order: modulus, public exponent, private exponent, p, q
func PackageRSAPublicKey ¶
PackageRSAPublicKey packages a public key into our own format. Packaging order: modulus, public exponent
func PostRequest ¶
func PostRequest(key *rsa.PublicKey, url string, body map[string]interface{}) (map[string]interface{}, error)
Send a post request (with TC protection encryption)
func PostRequestNoTC ¶
Send a post request without TC Protection
func SignRSA ¶
func SignRSA(privateKey *rsa.PrivateKey, message string) (string, error)
Sign a message with a private key.
func SuccessfulRequest ¶
func SuccessfulRequest(c *fiber.Ctx) error
func UnpackageRSAPrivateKey ¶
func UnpackageRSAPrivateKey(priv string) (*rsa.PrivateKey, error)
Unpackage private key (in our own format that is kinda crappy but who cares)
func UnpackageRSAPublicKey ¶
Unpackage public key (in our own format that is kinda crappy but who cares)
Types ¶
type ConnectionTokenClaims ¶
type ConnectionTokenClaims struct { Account string `json:"acc"` // Account id of the connecting client ExpiredUnixSec int64 `json:"e_u"` // Expiration time in unix seconds Session string `json:"ses"` // Session id of the connecting client Node string `json:"node"` // Node id of the node the client is connecting to Extra string `json:"extra,omitempty"` // Extra information for the connection jwt.RegisteredClaims }
Connection token struct