-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from vaslabs/feature/secureJoin
Feature/secure join
- Loading branch information
Showing
15 changed files
with
109 additions
and
68 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
19 changes: 4 additions & 15 deletions
19
endpoints/src/main/scala/cardgame/endpoints/JoiningGame.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 |
---|---|---|
@@ -1,31 +1,20 @@ | ||
package cardgame.endpoints | ||
|
||
import java.util.Base64 | ||
|
||
import cardgame.model.{ClockedResponse, GameId, PlayerId} | ||
import cardgame.json.circe._ | ||
import cardgame.model.{ClockedAction, ClockedResponse, GameId} | ||
import sttp.model.StatusCode | ||
import sttp.tapir._ | ||
import cardgame.json.circe._ | ||
import sttp.tapir.json.circe._ | ||
import cardgame.endpoints.codecs.rsa | ||
object JoiningGame { | ||
|
||
import codecs.ids._ | ||
import cardgame.endpoints.codecs.ids._ | ||
import schema.vector_clock._ | ||
|
||
val joinPlayer = | ||
endpoint.in( | ||
"game" / path[GameId] / "join" | ||
).post | ||
.in(query[PlayerId]("username")) | ||
.in( | ||
auth.bearer | ||
.map( | ||
rsa.fromString | ||
)(rsaKey => | ||
Base64.getEncoder.encodeToString(rsaKey.getEncoded) | ||
) | ||
) | ||
.in(jsonBody[ClockedAction]) | ||
.out(jsonBody[ClockedResponse]) | ||
.errorOut(statusCode(StatusCode.NotFound)) | ||
} |
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
11 changes: 5 additions & 6 deletions
11
endpoints/src/main/scala/cardgame/endpoints/codecs/ids.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 |
---|---|---|
@@ -1,16 +1,15 @@ | ||
package cardgame.endpoints.codecs | ||
|
||
import cardgame.model.{DeckId, GameId, PlayerId} | ||
import sttp.tapir.Codec | ||
import sttp.tapir.{Codec, CodecFormat} | ||
|
||
object ids { | ||
implicit val gameIdCodec = Codec.uuidPlainCodec | ||
implicit val gameIdCodec: Codec[String, GameId, CodecFormat.TextPlain] = Codec.uuid | ||
.map(GameId)(_.value) | ||
|
||
implicit val deckIdCodec = Codec.uuidPlainCodec.map(DeckId)(_.value) | ||
implicit val deckIdCodec: Codec[String, DeckId, CodecFormat.TextPlain] = Codec.uuid.map(DeckId)(_.value) | ||
|
||
implicit val playerId = Codec.stringPlainCodecUtf8.map( | ||
implicit val playerId: Codec[String, PlayerId, CodecFormat.TextPlain] = Codec.string.map( | ||
PlayerId | ||
)(_.value) | ||
} | ||
|
||
} |
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
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
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
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
Oops, something went wrong.