modulepackage
0.0.0-20240105124814-767b333ff2fd
Repository: https://github.com/sbstnerhrdt/identity.git
Documentation: pkg.go.dev
# README
Identity
An identity management system written in go using
- ORM (Object Relational Mapping) - Gorm
- JWT (JSON Web Token)
- Gin (HTTP framework)
- GraphQL
Status
Under development
⚠️ Experimental - Not ready for production.
TODO
- Resend confirmation email
- Add more tests
- Add documentation
- Add examples
Author
Sebastian Erhardt
Environment Variables
SMPT_USER=user_name
SMPT_PASSWORD=secure_password
SMPT_SERVER=email-smtp.eu-central-1.amazonaws.com
SMPT_PORT=465
SECURITY_JWT_AUDIENCE=APP
SECURITY_JWT_API_AUDIENCE=API
SECURITY_PEPPER={{SECURE_RANDOM_STRING}}
SECURITY_JWT_SECRET={{SECURE_RANDOM_STRING}}
SECURITY_JWT_ISSUER=YOUR_DOMAIN
Usage
s := identity.NewService("APP", mail.Address{
Name: "App",
Address: "[email protected]",
}).
SetSQLClient(connections.SQLClient).
SetAuthConfirmationEndpoint("https://exameple.com/auth/confirm")
Processes
Registration
- Check if identity already exists
- Create new identity
- Create confirmation token link
- Send email / sms with confirmation link
Link endpoint
Auth Confirmation Endpoint + /registration/{{Random Token}}
e.g.
https://exameple.com/auth/confirm/registration/esrdzh534253qreafdsrgrqafeaar
- Activate account
If the activation is expired, the account will be deleted. The user will be able to register again.
Invitation
- Check if identity already exists
- If identity exists already:
- Create reference to entity
- send info email
- If identity does not exist:
- Create invitation token
- Create reference to entity
- Send email with invitation link
- Register with password
- If identity exists already:
Login
- Check if identity exists
- Checks if identity is active
- Checks if identity is blocked
- Checks if identity is cleared
- Generate token
- Save ip and agent
Lost Password
OWASP Forgot Password Checklist
The following short guidelines can be used as a quick reference to protect the forgot password service:
- Return a consistent message for both existent and non-existent accounts.
- Ensure that the time taken for the user response message is uniform.
- Use a side-channel to communicate the method to reset their password.
- Use URL tokens for the simplest and fastest implementation.
- Ensure that generated tokens or codes are:
- Randomly generated using a cryptographically safe algorithm.
- Sufficiently long to protect against brute-force attacks.
- Stored securely.
- Single use and expire after an appropriate period.
- Do not make a change to the account until a valid token is presented, such as locking out the account
Process
- Generate Token
- Send Email with password change confirmation token link
- Reset password
Change Email
- Generate Token
- Send Email with confirmation token link to old email
- Send Email with confirmation token link to new email
- Change email
- Send confirmation email
Password
https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html
- Password Length
- Minimum length of the passwords should be enforced by the application. Passwords shorter than 8 characters are considered to be weak (NIST SP800-63B).
- Maximum password length should not be set too low, as it will prevent users from creating passphrases. A common maximum length is 64 characters due to limitations in certain hashing algorithms, as discussed in the Password Storage Cheat Sheet. It is important to set a maximum password length to prevent long password Denial of Service attacks.
API Token
- Users can generate API tokens with a longer lifetime
- Users can delete API tokens
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Functions
No description provided by the author