A Scala and ZIO playground which happens to be an auth service.
./sbt app/run
brew cask install java11
brew install cassandra
(will also installcqlsh
)- Cassandra doesn't work with java 14 (we are using java 11)
- Some jvm options doesn't work so we have to edit
/usr/local/etc/cassandra/jvm.options
- Launch with
cassandra -f
- Stop with
ctrl c
orps
to get the PID and thenkill <PID>
- Default host and port is
127.0.0.1:9042
cqlsh
will connect there by defaultCREATE KEYSPACE IF NOT EXISTS thewho_dummy WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
- Edit
app/Main
andbuild.sbt
to use cassandra instead of in memory db
- Edit
app/Main
andbuild.sbt
to use http4s instead of finch. Seeserver/http4s/Server
- Edit
app/Main
andbuild.sbt
to use postgres instead of in memory db - Add
127.0.0.1 postgres
to your/etc/hosts
file docker-compose up
docker exec -it postgres bash
psql -d postgres -U postgres
ENDPOINT | METHOD | INPUT | OUTPUT | STATUS CODES |
---|---|---|---|---|
/signup | POST | Credential |
TokenResponse |
201, 209, 422, 500 |
/login | GET, POST | Credential |
TokenResponse |
200, 401 403, 404, 422, 500 |
/change-password | POST | CredentialSecretUpdateRequest |
TokenResponse |
200, 401 403, 404, 422, 500 |
/signout | POST | Credential |
empty |
204, 401 403, 404, 422, 500 |
/find-credential-id | POST | UserCredentialIdRequest |
UserCredentialIdResponse |
200, 401 403, 404, 422, 500 |
Credential: { id: String, secret: String }
CredentialSecretUpdateRequest: { oldCredential: Credential, newSecret: String }
TokenResponse: { token: String }
UserCredentialIdRequest: { token: String }
UserCredentialIdResponse: { credentialId: String }
./sbt gatling/gatling:test
./sbt test
- To generate key pairs:
openssl genrsa -out private.pem 1024
openssl rsa -in private.pem -pubout -outform PEM -out public_key.pem
openssl pkcs8 -topk8 -inform PEM -in private.pem -out private_key.pem -nocrypt
the last line is needed because of the format java uses.
- Sending json thru httpie:
echo '{ "id": "Salvador", "secret": "Dalí" }' | http POST http://127.0.0.1:8080/signup -v
echo '{ "oldCredential": { "id": "Salvador", "secret": "Dalí" }, "newSecret": "lanadanisman" }' | http POST http://127.0.0.1:8080/change-password -v