Skip to content

Commit

Permalink
#291 Add basic authentication to Stream API
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Aug 24, 2017
1 parent 47bfae9 commit fae95cb
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions thehive-backend/app/controllers/StreamCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import services.StreamActor.StreamMessages

import org.elastic4play.controllers._
import org.elastic4play.services.{ AuxSrv, EventSrv, MigrationSrv, Role }
import org.elastic4play.{ AuthenticationError, Timed }
import org.elastic4play.Timed

@Singleton
class StreamCtrl(
Expand Down Expand Up @@ -98,16 +98,17 @@ class StreamCtrl(
Future.successful(BadRequest("Invalid stream id"))
}
else {
val status = authenticated.expirationStatus(request) match {
case ExpirationError if !migrationSrv.isMigrating throw AuthenticationError("Not authenticated")
case _: ExpirationWarning 220
case _ OK

val futureStatus = authenticated.expirationStatus(request) match {
case ExpirationError if !migrationSrv.isMigrating authenticated.getFromApiKey(request).map(_ OK)
case _: ExpirationWarning Future.successful(220)
case _ Future.successful(OK)
}

(system.actorSelection(s"/user/stream-$id") ? StreamActor.GetOperations) map {
case StreamMessages(operations) renderer.toOutput(status, operations)
case m InternalServerError(s"Unexpected message : $m (${m.getClass})")
futureStatus.flatMap { status
(system.actorSelection(s"/user/stream-$id") ? StreamActor.GetOperations) map {
case StreamMessages(operations) renderer.toOutput(status, operations)
case m InternalServerError(s"Unexpected message : $m (${m.getClass})")
}
}
}
}
Expand Down

0 comments on commit fae95cb

Please sign in to comment.