Skip to content

Commit

Permalink
skip auth when flag=embed
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Aug 2, 2024
1 parent 896ade3 commit 4cd35d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/scala/Auth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ final class Auth(mongo: Mongo, seenAt: SeenAtUpdate, config: Config)(using Execu
import Mongo.given

def apply(req: RequestHeader): Future[Option[Success]] =
if req.flag contains Flag.api then Future.successful(None)
if req.flag.exists(flag => flag == Flag.api || flag == Flag.embed)
then Future.successful(None)
else
sessionIdFromReq(req) match
case Some(sid) if sid.startsWith(appealPrefix) => Future.successful(None)
Expand Down
7 changes: 4 additions & 3 deletions src/main/scala/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ opaque type Flag = String
object Flag extends OpaqueString[Flag]:
def make(value: String) =
value match
case "simul" | "tournament" | "api" => Some(Flag(value))
case _ => None
val api = Flag("api")
case "simul" | "tournament" | "api" | "embed" => Some(Flag(value))
case _ => None
val api = Flag("api")
val embed = Flag("embed")

opaque type IpAddress = String
object IpAddress extends OpaqueString[IpAddress]
Expand Down

0 comments on commit 4cd35d8

Please sign in to comment.