Skip to content

Commit

Permalink
#1410 Add logout API
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 17, 2020
1 parent d9a6838 commit 86ee6dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 5 additions & 4 deletions thehive/app/org/thp/thehive/controllers/v0/Router.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ class Router @Inject() (

case POST(p"/_stats") => statsCtrl.stats

case GET(p"/status") => statusCtrl.get
case GET(p"/health") => statusCtrl.health
case GET(p"/logout") => authenticationCtrl.logout
case POST(p"/login") => authenticationCtrl.login
case GET(p"/status") => statusCtrl.get
case GET(p"/health") => statusCtrl.health
case GET(p"/logout") => authenticationCtrl.logout
case POST(p"/logout") => authenticationCtrl.logout
case POST(p"/login") => authenticationCtrl.login
// case POST(p"/ssoLogin") => authenticationCtrl.ssoLogin

case DELETE(p"/case/shares") => shareCtrl.removeShares()
Expand Down
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/controllers/v1/AuditCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AuditCtrl @Inject() (
)
override val outputQuery: Query = Query.output[RichAudit, AuditSteps](_.richAudit)

def flow(): Action[AnyContent] =
def flow: Action[AnyContent] =
entrypoint("audit flow")
.authRoTransaction(db) { implicit request => implicit graph =>
val audits = auditSrv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class AuthenticationCtrl @Inject() (
} yield authSrv.setSessionUser(authContext)(Results.Ok(user.toJson))
}

def logout: Action[AnyContent] = entrypoint("logout") { _ =>
Success(Results.Ok.withNewSession)
}

def withTotpAuthSrv[A](body: TOTPAuthSrv => Try[A]): Try[A] =
authSrv match {
case totpAuthSrv: TOTPAuthSrv if totpAuthSrv.enabled => body(totpAuthSrv)
Expand Down
6 changes: 4 additions & 2 deletions thehive/app/org/thp/thehive/controllers/v1/Router.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class Router @Inject() (
case GET(p"/status") => statusCtrl.get
// GET /health controllers.StatusCtrl.health
// GET /logout controllers.AuthenticationCtrl.logout()
case POST(p"/login") => authenticationCtrl.login()
case GET(p"/logout") => authenticationCtrl.logout
case POST(p"/logout") => authenticationCtrl.logout
case POST(p"/login") => authenticationCtrl.login
case POST(p"/auth/totp/set") => authenticationCtrl.totpSetSecret
case POST(p"/auth/totp/unset") => authenticationCtrl.totpUnsetSecret(None)
case POST(p"/auth/totp/unset/$user") => authenticationCtrl.totpUnsetSecret(Some(user))
Expand Down Expand Up @@ -89,7 +91,7 @@ class Router @Inject() (
// DELETE /alert/:alertId controllers.AlertCtrl.delete(alertId)
// POST /alert/:alertId/merge/:caseId controllers.AlertCtrl.mergeWithCase(alertId, caseId)

case GET(p"/audit") => auditCtrl.flow()
case GET(p"/audit") => auditCtrl.flow
// GET /flow controllers.AuditCtrl.flow(rootId: Option[String], count: Option[Int])
// GET /audit controllers.AuditCtrl.find()
// POST /audit/_search controllers.AuditCtrl.find()
Expand Down

0 comments on commit 86ee6dd

Please sign in to comment.