Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/app/io/flow/play/controllers/Authorization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class AuthorizationImpl @Inject() (
config: Config,
) {

private[this] lazy val jwtSalt = {
config.requiredString("JWT_SALT")
}
private[this] lazy val jwtSalt =
config.optionalString("jwt.salt").getOrElse(config.requiredString("JWT_SALT"))

def get(value: Option[String]): Option[Authorization] = {
value.flatMap { get }
Expand Down
5 changes: 3 additions & 2 deletions lib/app/io/flow/play/util/AuthHeaders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import io.flow.util.Constants
import io.flow.common.v0.models.{CustomerReference, Environment, Role, UserReference}
import javax.inject.{Inject, Singleton}

/** Creates a valid X-Flow-Auth header for talking directly to a service. Bound config must have a JWT_SALT parameter.
/** Creates a valid X-Flow-Auth header for talking directly to a service. Bound config must have a jwt.salt (or legacy
* JWT_SALT) parameter.
*/
@Singleton
class AuthHeaders @Inject() (
config: Config,
) {

val FlowRequestId = "X-Flow-Request-Id"
private[this] lazy val jwtSalt = config.requiredString("JWT_SALT")
private[this] lazy val jwtSalt = config.optionalString("jwt.salt").getOrElse(config.requiredString("JWT_SALT"))

def headers(auth: AuthData): Seq[(String, String)] = {
Seq(
Expand Down
2 changes: 1 addition & 1 deletion lib/test/io/flow/play/controllers/AuthorizationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AuthorizationSpec extends LibPlaySpec {

def createJWTHeader(
userId: String,
salt: String = mockConfig.requiredString("JWT_SALT"),
salt: String = mockConfig.optionalString("jwt.salt").getOrElse(mockConfig.requiredString("JWT_SALT")),
): String = {
val token = JwtJson.encode(Json.obj("id" -> userId), salt, HS256)
s"Bearer $token"
Expand Down