Add end-point for returning the token for evaluation triggering

This commit is contained in:
Filip Gralinski 2021-08-31 22:36:10 +02:00
parent f0a2cde5db
commit 3f0d0ecff3
4 changed files with 28 additions and 0 deletions

View File

@ -179,6 +179,7 @@ instance Yesod App where
isAuthorized (ChallengeAllSubmissionsJsonR _) _ = return Authorized isAuthorized (ChallengeAllSubmissionsJsonR _) _ = return Authorized
isAuthorized AddUserR _ = return Authorized isAuthorized AddUserR _ = return Authorized
isAuthorized UserInfoR _ = return Authorized isAuthorized UserInfoR _ = return Authorized
isAuthorized MyEvaluationTriggerTokenJsonR _ = return Authorized
isAuthorized (ChallengeSubmissionJsonR _) _ = return Authorized isAuthorized (ChallengeSubmissionJsonR _) _ = return Authorized
isAuthorized (ChallengeReadmeInMarkdownR _) _ = regularAuthorization isAuthorized (ChallengeReadmeInMarkdownR _) _ = regularAuthorization
isAuthorized (QueryJsonR _) _ = regularAuthorization isAuthorized (QueryJsonR _) _ = regularAuthorization

View File

@ -1138,6 +1138,11 @@ getUserInfoR = do
(Entity _ user) <- requireAuthPossiblyByToken (Entity _ user) <- requireAuthPossiblyByToken
return $ String $ userIdent user return $ String $ userIdent user
getMyEvaluationTriggerTokenJsonR :: Handler Value
getMyEvaluationTriggerTokenJsonR = do
(Entity _ user) <- requireAuthPossiblyByToken
return $ String $ fromMaybe "" $ userTriggerToken user
getAddUserR :: Handler Value getAddUserR :: Handler Value
getAddUserR = do getAddUserR = do
mInfo <- authorizationTokenAuth mInfo <- authorizationTokenAuth
@ -1244,6 +1249,26 @@ declareUserInfoApi = do
& at 200 ?~ Inline response)) & at 200 ?~ Inline response))
] ]
myEvaluationTriggerTokenApi :: Swagger
myEvaluationTriggerTokenApi = spec & definitions .~ defs
where
(defs, spec) = runDeclare declareMyEvaluationTriggerTokenApi mempty
declareMyEvaluationTriggerTokenApi :: Declare (Definitions Schema) Swagger
declareMyEvaluationTriggerTokenApi = do
-- param schemas
response <- declareResponse (Proxy :: Proxy String)
return $ mempty
& paths .~
fromList [ ("/api/my-evaluation-trigger-token",
mempty & DS.get ?~ (mempty
& parameters .~ [ ]
& produces ?~ MimeList ["application/json"]
& description ?~ "Returns the token for triggering evaluations"
& at 200 ?~ Inline response))
]
declareAllSubmissionsApi :: String -> String -> Declare (Definitions Schema) Swagger declareAllSubmissionsApi :: String -> String -> Declare (Definitions Schema) Swagger

View File

@ -19,6 +19,7 @@ apiDescription :: Swagger
apiDescription = generalApi apiDescription = generalApi
<> addUserApi <> addUserApi
<> userInfoApi <> userInfoApi
<> myEvaluationTriggerTokenApi
<> listChallengesApi <> listChallengesApi
<> leaderboardApi <> leaderboardApi
<> allSubmissionsApi <> allSubmissionsApi

View File

@ -33,6 +33,7 @@
/api/version-info/#Text VersionInfoJsonR GET /api/version-info/#Text VersionInfoJsonR GET
/api/list-tags ListTagsJsonR GET /api/list-tags ListTagsJsonR GET
/api/my-teams MyTeamsJsonR GET /api/my-teams MyTeamsJsonR GET
/api/my-evaluation-trigger-token MyEvaluationTriggerTokenJsonR GET
/list-archived-challenges ListArchivedChallengesR GET /list-archived-challenges ListArchivedChallengesR GET
/my-teams MyTeamsR GET /my-teams MyTeamsR GET