Userme gives you a bunch of API services for basic account creation, token validation, user authentication, password reset, mail validation etc
See a full usage example at http://github.com/stutzlab/userme-demo-ui.
version: '3.6'
services:
userme:
image: stutzlab/userme
ports:
- "7000:7000"
restart: always
environment:
- LOG_LEVEL=debug
- DB_DIALECT=sqlite3
- MAIL_SMTP_HOST=mailslurper
- MAIL_SMTP_PORT=2500
- MAIL_SMTP_USER=test
- MAIL_SMTP_PASS=test
- MAIL_FROM_NAME=Berimbal
- MAIL_FROM_ADDRESS=test@test.com
- MAIL_ACTIVATION_SUBJECT=Activate your account at Berimbau.com!
- MAIL_ACTIVATION_HTML=<b>Hi DISPLAY_NAME</b>, <p> <a href=https://test.com/activate?t=ACTIVATION_TOKEN>Click here to complete your registration</a><br>Be welcome!</p> <p>-Test Team.</p>
- MAIL_PASSWORD_RESET_SUBJECT=Password reset requested at Berimbau.com
- MAIL_PASSWORD_RESET_HTML=<b>Hi DISPLAY_NAME</b>, <p> <a href=https://test.com/reset-password?t=PASSWORD_RESET_TOKEN>Click here to reset your password</a></p><p>-Test Team.</p>
- MAIL_TOKENS_FOR_TESTS=true
- ACCOUNT_ACTIVATION_METHOD=mail
- JWT_SIGNING_METHOD=ES256
secrets:
- jwt-signing-key
mailslurper:
image: marcopas/docker-mailslurper
ports:
- "8080:8080"
- "8085:8085"
- "2500:2500"
restart: always
secrets:
jwt-signing-key:
file: ./tests/test-key.pem
Run docker-compose up
Create a new user
curl -v --location --request PUT 'http://localhost:7000/user/test1@test.com' \
--header 'Content-Type: application/json' \
--data-raw '{
"password": "testtest",
"name": "test1@test.com"
}'
curl -v --location --request POST 'http://localhost:7000/user/test1@test.com/activate' \
--header 'Authorization: Bearer <TOKEN FROM MAIL LINK>'
curl -v --location --request POST 'http://localhost:7000/token' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "test1@test.com",
"password": "testtest"
}'
curl --location --request GET 'http://localhost:7000/token' \
--header 'Authorization: Bearer <TOKEN FROM POST /token>'
PUT /user/:email
POST /user/:email/activate
POST /user/:email/password-reset-request
POST /user/:email/password-reset-change
POST /user/:email/password-change
POST /token
POST /token/refresh
GET /token
LOG_LEVEL - Application log details level. defaults to 'info'
CORS_ALLOWED_ORIGINS - Browser origin domains allowed to invoke this service. defaults to '*'
ACCESS_TOKEN_EXPIRATION_MINUTES - Access Token expiration time after creation. This is the token used in requests to the server. If you want to extend this time, use a Refresh Token to get a new Access Token at endpoint /token/refresh. defaults to '30'
REFRESH_TOKEN_EXPIRATION_MINUTES - Refresh token expiration time. This token can be used to get new Access Tokens, but we will verify if this account is enabled/unlock before doing so. Probably much higher than access tokens expiration because this token can be used to extend long time authentications, for example, for supporting mobile applications to keep authenticated after being closed etc. defaults to '40320'
VALIDATION_TOKEN_EXPIRATION_MINUTES - Validation token expiration in minutes. This is the time the link sent to email will remain valid. defaults to '20'
PASSWORD_RESET_TOKEN_EXPIRATION_MINUTES - Password reset token expiration in minutes. This is the time the link sent to email will remain valid. defaults to '5'
ACCESS_TOKEN_DEFAULT_SCOPE - Scope (claim) included in all tokens indicating a good authentication. defaults to 'basic'
INCORRECT_PASSWORD_MAX_RETRIES - Max number of wrong password retries during user authentication before the account gets locked (then it will need a "password reset"). defaults to '5'
INCORRENT_PASSWORD_TIME_SECONDS - Time to permit a new password retry base. This base is doubled each time the user misses the password. For example: With value of '1', the user can do the first retry after 1 second, the second retry after 2 seconds, third retry after 4 seconds, forth retry after 8 seconds until reaching MAX_RETRIES. defaults to '1'
ACCOUNT_ACTIVATION_METHOD - Whetever activate account immediately after user creation ('direct') or send an "activation link" to the user e-mail ('email'). defaults to 'direct'
PASSWORD_VALIDATION_REGEX - Regex used against new user passwords. defaults to '^.{6,30}$'
PASSWORD_EXPIRATION_DAYS - Password expiration days after changing it (will force the user to change the password upon login). -1 means no expiration. defaults to -1
JWT_ISSUER - JWT 'iss' field contents. Used as the 'name' of mail from too.
JWT_SIGNING_METHOD - JWT algorithm used to sign tokens. defaults to 'ES256'
JWT_SIGNING_KEY_FILE - PEM file path containing the key used on JWT token signatures. In Docker, user "secrets" to store this kind of information. defaults to '/run/secrets/jwt-signing-key'
MATER_PUBLIC_KEY_FILE - File path containing the Public Key used to sign special "master" tokens that can be used to perform some administrative operations on Userme. In Docker, user "secrets" to store this kind of information. defaults to '/run/secrets/jwt-private-key'
DB_DIALECT - One of 'mysql', 'postgres', 'sqlite3' or 'mssql'. defaults to 'mysql'
DB_HOST - database hostname. required
DB_PORT - database port. required
DB_USERNAME - database connection username. defaults to 'userme'
DB_PASSWORD - database connection password. required
DB_NAME - database name. defaults to 'userme'
MAIL_SMTP_HOST - smtp mail sender host. defaults to 'smtp.mailgun.com'
MAIL_SMTP_PORT - secure (tls) smtp port. defaults to '465'
MAIL_SMTP_USER - smtp authentication username. required
MAIL_SMTP_PASS - smtp authentication password. required
MAIL_FROM_ADDRESS - Send emails using this "mail from" info. required
MAIL_ACTIVATION_SUBJECT - Mail Subject used on account activation messages. required. Example: Activate your account at Berimbau.com!
MAIL_ACTIVATION_HTML - Mail HTML Body used on account activation messages. Use $DISPLAY_NAME and $ACTIVATION_TOKEN for string templating. required. Example: <b>Hi $DISPLAY_NAME</b>, <p> <a href=https://test.com/activate?t=$ACTIVATION_TOKEN>Click here to complete your registration</a><br>Be welcome!</p> <p>-Test Team.</p>
MAIL_PASSWORD_RESET_SUBJECT - Mail Subject used on password reset messages. required. Example: Password reset requested at Test.com
MAIL_PASSWORD_RESET_HTML - Mail HTML Body used on password reset messages. Use $DISPLAY_NAME and $PASSWORD_RESET_TOKEN for string templating. required. Example: <b>Hi $DISPLAY_NAME</b>, <p> <a href=https://test.com/reset-password?t=$PASSWORD_RESET_TOKEN>Click here to reset your password</a></p><p>-Test Team.</p>
MAIL_TOKENS_FOR_TESTS - If true, adds password reset and account activation tokens in http response headers with name "TestToken" so that automated scripts can proceed with tests that needs those tokens. NEVER USE THIS IN PRODUCTION as it will make the e-mail (second factor) useless for security matters. defaults to false
markdown-swagger swagger.yaml README.md
Import tests/collection.json to Postman so that you can test and update the automated tests