https://github.com/doga/qworum-demo-auth
Qworum service for authenticating the end-user.
https://github.com/doga/qworum-demo-auth
Last synced: 6 months ago
JSON representation
Qworum service for authenticating the end-user.
- Host: GitHub
- URL: https://github.com/doga/qworum-demo-auth
- Owner: doga
- License: apache-2.0
- Created: 2024-11-03T09:43:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-03T17:27:17.000Z (over 1 year ago)
- Last Synced: 2024-11-03T18:16:41.689Z (over 1 year ago)
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Demo of a Qworum service that does user authentication
## Qworum API endpoints
- the `home` endpoint, which is a test application.
- the `sign-in` endpoint, called by `home`.
- the `sign-up` endpoint, called by `sign-in`.
## Create user credentials
Use this script to populate `dist/data/credentials.json`.
First install these:
1. [Deno 2+](https://deno.com/)
1. [MDRB](https://jsr.io/@andrewbrey/mdrb)
Then run this:
```shell
mdrb --mode isolated https://raw.githubusercontent.com/doga/qworum-demo-auth/master/README.md
```
This will run the following script:
Create SHA-256 digests from cleartext passwords.
description = '''
This script will not touch the filesystem.
'''
```javascript
const
algorithm = 'SHA-256',
prompt = 'Password? (leave empty to exit)',
digest = async (message) => {
const
msgUint8 = new TextEncoder().encode(message), // encode as (utf-8) Uint8Array
hashBuffer = await crypto.subtle.digest(algorithm, msgUint8), // hash the message
hashArray = Array.from(new Uint8Array(hashBuffer)), // convert buffer to byte array
hashHex = hashArray
.map((b) => b.toString(16).padStart(2, "0"))
.join(""); // convert bytes to hex string
return hashHex;
};
while(true){
const password = await $.prompt(prompt); if(password.length === 0) break;
const passwordDigest = await digest(password);
console.info(`Password:\n ${password}\n${algorithm} digest in hexadecimals:\n ${passwordDigest}\n`);
}
```
Sample output:
```text
Password:
password
SHA-256 digest in hexadecimals:
5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
```
## License
This software is released under the terms of the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0).
∎