Starter JWT Auth server written in TypeScript with Deno. Doesn't provide API solution. Used only as a user authenticator and JWT generator.
Use POST
with route /auth
.
Query:
localhost:3001/auth
Body:
{
"username": "some name",
"namespace": "some namespace",
"password": "some password"
}
Response in JSON
property | content | description |
---|---|---|
message |
string |
Invalid credentials |
jwt |
token |
Your valid token |
To run built version of auth server copy and run command above. The need of flags is written in SRC section.
deno run ---allow-read=config.json --allow-net=127.0.0.1 build/server.bundle.js
deno run ---allow-read=config.json --allow-net=127.0.0.1 build/cli.bundle.js -m createUser
Used for development
deno run ---allow-read=config.json --allow-net=127.0.0.1 -c src/tsconfig.json src/server.ts
flag | description |
---|---|
allow-net |
MySQL connection, http server |
allow-read |
config load |
deno bundle src/server.ts build/server.bundle.js -c src/tsconfig.json --unstable
Possibility to create user, delete user and change user password in CLI from file cli.ts
. Argument -m
(method) is required.
method |
---|
createUser |
deleteUser |
updateUserPassword |
deno run --allow-net=127.0.0.1 --allow-read=config.json -c src/tsconfig.json src/cli.ts -m createUser
flag | description |
---|---|
allow-net |
used for MySQL connection |
parameter | description |
---|---|
experimentalDecorators |
needed by /x/dso ORM |
deno bundle src/cli.ts build/cli.bundle.js -c src/tsconfig.json --unstable
Carefuly! This recreates and clears whole database!
deno test src/tests/auth.test.ts --allow-net=127.0.0.1 --allow-read=config.json -c src/tsconfig.json