-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cats #5
Merged
Cats #5
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
288befc
Cats version with some http, grpc and db
KacperFKorban 1d875e8
Make db name more generic in code
KacperFKorban 55b9006
Basic http for stats and kafka client (Vanilla might not compile)
KacperFKorban 3b93f77
Fix vanilla and ZIO compilation
KacperFKorban 037d8f8
Cats stats grpc
KacperFKorban 27b9d2a
Change logic to actual pwned
KacperFKorban b6a4b8f
Fix fetching known hashes from db, move normalization to separate ste…
KacperFKorban c4e6826
Change fors to parTupled where possible
KacperFKorban 168175f
Add config with ciris for base service
KacperFKorban e28a1d6
Add config for stats service
KacperFKorban 24510ea
Add tracing in base cats
KacperFKorban a2ac333
Add documentation explaining most of the code on a top-level
KacperFKorban 55b2fee
Simplify logic
KacperFKorban 1071977
Adjust slightly architecture diagram
liosedhel 1c4f675
Review fixes and reworks
KacperFKorban bdd3f29
Some more review fixes
KacperFKorban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
create table hashed_passwords( | ||
KacperFKorban marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uuid UUID DEFAULT gen_random_uuid() PRIMARY KEY, | ||
password VARCHAR NOT NULL, | ||
KacperFKorban marked this conversation as resolved.
Show resolved
Hide resolved
|
||
hash_type VARCHAR NOT NULL, | ||
password_hash VARCHAR NOT NULL, | ||
UNIQUE (hash_type, password) | ||
KacperFKorban marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); |
37 changes: 37 additions & 0 deletions
37
commons/src/main/scala/com/virtuslab/vss/common/BaseEndpoints.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.virtuslab.vss.common | ||
KacperFKorban marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import sttp.tapir.* | ||
import sttp.tapir.generic.auto.* | ||
import sttp.tapir.json.upickle.* | ||
import upickle.default.* | ||
|
||
object BaseEndpoints: | ||
|
||
val checkPasswordEndpoint: Endpoint[Unit, CheckPwned, Unit, CheckedPwned, Any] = sttp.tapir.endpoint.post | ||
KacperFKorban marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.in("check") | ||
.in(jsonBody[CheckPwned].example(CheckPwned("5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"))) | ||
.out(jsonBody[CheckedPwned].example(CheckedPwned("5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", true))) | ||
|
||
val hashPasswordEndpoint: Endpoint[Unit, HashPassword, Unit, HashedPassword, Any] = sttp.tapir.endpoint.post | ||
.in("hash") | ||
.in(jsonBody[HashPassword].example(HashPassword("SHA256", "password"))) | ||
.out( | ||
jsonBody[HashedPassword] | ||
.example(HashedPassword("SHA256", "password", "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8")) | ||
) | ||
|
||
case class CheckPwned(passwordHash: String) | ||
object CheckPwned: | ||
given ReadWriter[CheckPwned] = macroRW | ||
|
||
case class CheckedPwned(passwordHash: String, pwned: Boolean) | ||
object CheckedPwned: | ||
given ReadWriter[CheckedPwned] = macroRW | ||
|
||
case class HashPassword(hashType: String, password: String) | ||
object HashPassword: | ||
given ReadWriter[HashPassword] = macroRW | ||
|
||
case class HashedPassword(hashType: String, password: String, hash: String) | ||
object HashedPassword: | ||
given ReadWriter[HashedPassword] = macroRW |
24 changes: 0 additions & 24 deletions
24
commons/src/main/scala/com/virtuslab/vss/common/HashPasswordHttpEndpoints.scala
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
commons/src/main/scala/com/virtuslab/vss/common/StatsEndpoints.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.virtuslab.vss.common | ||
|
||
import sttp.tapir.* | ||
import sttp.tapir.generic.auto.* | ||
import sttp.tapir.json.upickle.* | ||
import upickle.default.* | ||
|
||
object StatsEndpoints: | ||
|
||
val getAllEvents: Endpoint[Unit, Unit, Unit, List[Event], Any] = sttp.tapir.endpoint.get | ||
.in("allevents") | ||
.out(jsonBody[List[Event]].example(List(Event.CheckedPwned("5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8")))) |
14 changes: 14 additions & 0 deletions
14
commons/src/main/scala/com/virtuslab/vss/common/events.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.virtuslab.vss.common | ||
|
||
import upickle.default.* | ||
|
||
enum Event: | ||
case HashedPassword(password: String, hashType: String) | ||
case CheckedPwned(passwordHash: String) | ||
|
||
object Event { | ||
given ReadWriter[Event] = ReadWriter.merge( | ||
macroRW[Event.HashedPassword], | ||
macroRW[Event.CheckedPwned] | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: '3.8' | ||
services: | ||
db: | ||
restart: always | ||
image: postgres:14.1-alpine | ||
ports: | ||
- "5432:5432" | ||
environment: | ||
- DEBUG=true | ||
- POSTGRES_DB=vss | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=postgres | ||
volumes: | ||
- ./commons/src/main/resources/tables.sql:/docker-entrypoint-initdb.d/init.sql | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
zookeeper: | ||
image: confluentinc/cp-zookeeper:7.3.2 | ||
environment: | ||
ZOOKEEPER_CLIENT_PORT: 2181 | ||
ZOOKEEPER_TICK_TIME: 2000 | ||
|
||
kafka: | ||
image: confluentinc/cp-kafka:7.3.2 | ||
ports: | ||
- "9092:9092" | ||
depends_on: | ||
- zookeeper | ||
environment: | ||
KAFKA_BROKER_ID: 1 | ||
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181' | ||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT | ||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092 | ||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | ||
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 | ||
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 | ||
|
||
jaeger: | ||
image: jaegertracing/all-in-one:latest | ||
ports: | ||
- "5775:5775/udp" | ||
- "16686:16686" # Jaeger UI port | ||
- "6831:6831/udp" # Jaeger Thrift Compact Protocol port | ||
- "6832:6832/udp" | ||
- "5778:5778" | ||
- "14268:14268" | ||
- "9411:9411" | ||
environment: | ||
- COLLECTOR_ZIPKIN_HTTP_PORT=9411 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") | ||
|
||
val zioGrpcVersion = "0.6.0-rc4" | ||
libraryDependencies ++= Seq( | ||
"com.thesamet.scalapb.zio-grpc" %% "zio-grpc-codegen" % zioGrpcVersion | ||
) | ||
libraryDependencies ++= Seq("com.thesamet.scalapb.zio-grpc" %% "zio-grpc-codegen" % "0.6.0-rc4") | ||
addSbtPlugin("org.typelevel" % "sbt-fs2-grpc" % "2.5.11") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM hseeberger/scala-sbt | ||
|
||
WORKDIR /.. | ||
|
||
# Copy your source code into the container | ||
COPY . .. | ||
|
||
# Compile your Scala application | ||
RUN sbt compile | ||
|
||
# Define the command to start your application | ||
CMD ["sbt", "vss_cats/run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
syntax = "proto3"; | ||
LukBed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
package com.virtuslab.vss.proto.cats; | ||
|
||
// Base | ||
|
||
message HashPasswordMessage { | ||
string hashType = 1; | ||
string password = 2; | ||
} | ||
|
||
message HashedPasswordMessage { | ||
string hashType = 1; | ||
string password = 2; | ||
string hash = 3; | ||
} | ||
|
||
service HashPasswordService { | ||
rpc HashPassword (HashPasswordMessage) returns (HashedPasswordMessage) {} | ||
} | ||
|
||
message CheckPwnedRequest { | ||
string passwordHash = 1; | ||
} | ||
|
||
message CheckPwnedResponse { | ||
string passwordHash = 1; | ||
bool pwned = 2; | ||
} | ||
|
||
service PwnedService { | ||
rpc CheckPwned (CheckPwnedRequest) returns (CheckPwnedResponse) {} | ||
} | ||
|
||
// Stats | ||
|
||
message EmptyRequest {} | ||
|
||
message EventResponse { | ||
string eventType = 1; | ||
optional string password = 2; | ||
optional string hashType = 3; | ||
optional string passwordHash = 4; | ||
} | ||
|
||
message AllEvents { | ||
repeated EventResponse events = 1; | ||
} | ||
|
||
service StatsService { | ||
rpc GetAllEvents (EmptyRequest) returns (AllEvents) {} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] the drawing is very hard to read with dark mode :)