Skip to content

Commit

Permalink
move CSP and Nonce out of modules/common
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Apr 29, 2023
1 parent b3405ba commit 4e89317
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions app/controllers/LilaController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import play.api.mvc.*
import scala.annotation.nowarn
import scalatags.Text.Frag

import lila.api.{ BodyContext, Context, HeaderContext, PageData }
import lila.api.{ BodyContext, Context, HeaderContext, PageData, Nonce }
import lila.app.{ *, given }
import lila.common.{ ApiVersion, HTTPRequest, Nonce }
import lila.common.{ ApiVersion, HTTPRequest, config }
import lila.i18n.{ I18nKey, I18nLangPicker }
import lila.oauth.{ OAuthScope, OAuthServer }
import lila.security.{ AppealUser, FingerPrintedUser, Granter, Permission }
import lila.user.{ Holder, User as UserModel, UserContext }
import lila.common.config

abstract private[controllers] class LilaController(val env: Env)
extends BaseController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package lila.common
package lila.app

import lila.api.Nonce

case class ContentSecurityPolicy(
defaultSrc: List[String],
Expand Down
2 changes: 1 addition & 1 deletion app/http/ErrorHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class ErrorHandler(
val errorCtx = lila.api.Context.error(
req,
lila.i18n.defaultLang,
HTTPRequest.isSynchronousHttp(req) option lila.common.Nonce.random
HTTPRequest.isSynchronousHttp(req) option lila.api.Nonce.random
)
InternalServerError(views.html.site.bits.errorPage(using errorCtx))
else InternalServerError("Sorry, something went wrong.")
Expand Down
4 changes: 2 additions & 2 deletions app/templating/AssetHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package templating

import play.api.mvc.RequestHeader

import lila.api.Context
import lila.api.{ Context, Nonce }
import lila.app.ui.ScalatagsTemplate.*
import lila.common.{ AssetVersion, ContentSecurityPolicy, Nonce }
import lila.common.AssetVersion

trait AssetHelper extends HasEnv { self: I18nHelper with SecurityHelper =>

Expand Down
2 changes: 1 addition & 1 deletion app/ui/EmbedConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package ui
import play.api.mvc.RequestHeader
import play.api.i18n.Lang

import lila.common.Nonce
import lila.api.Nonce

case class EmbedConfig(
bg: String,
Expand Down
6 changes: 3 additions & 3 deletions app/views/base/layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import controllers.report.routes.{ Report as reportRoutes }
import controllers.routes
import play.api.i18n.Lang

import lila.api.{ AnnounceStore, Context }
import lila.api.{ Nonce, AnnounceStore, Context }
import lila.app.templating.Environment.{ given, * }
import lila.app.ContentSecurityPolicy
import lila.app.ui.ScalatagsTemplate.{ *, given }
import lila.common.base.StringUtils.escapeHtmlRaw
import lila.common.LangPath
import lila.common.String.html.safeJsonValue
import lila.common.{ ContentSecurityPolicy, Nonce }
import lila.common.LangPath

object layout:

Expand Down
2 changes: 1 addition & 1 deletion modules/api/src/main/Context.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package lila.api
import play.api.i18n.Lang
import play.api.mvc.RequestHeader

import lila.common.{ HTTPRequest, Nonce }
import lila.common.HTTPRequest
import lila.pref.Pref
import lila.user.{ BodyUserContext, HeaderUserContext, UserContext }
import lila.notify.Notification.UnreadCount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lila.common
package lila.api

import ornicar.scalalib.SecureRandom

Expand Down

0 comments on commit 4e89317

Please sign in to comment.