{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudFront.Types.ResponseHeadersPolicyXSSProtection
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudFront.Types.ResponseHeadersPolicyXSSProtection where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Determines whether CloudFront includes the @X-XSS-Protection@ HTTP
-- response header and the header\'s value.
--
-- For more information about the @X-XSS-Protection@ HTTP response header,
-- see
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
-- in the MDN Web Docs.
--
-- /See:/ 'newResponseHeadersPolicyXSSProtection' smart constructor.
data ResponseHeadersPolicyXSSProtection = ResponseHeadersPolicyXSSProtection'
  { -- | A Boolean that determines whether CloudFront includes the @mode=block@
    -- directive in the @X-XSS-Protection@ header.
    --
    -- For more information about this directive, see
    -- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
    -- in the MDN Web Docs.
    ResponseHeadersPolicyXSSProtection -> Maybe Bool
modeBlock :: Prelude.Maybe Prelude.Bool,
    -- | A reporting URI, which CloudFront uses as the value of the @report@
    -- directive in the @X-XSS-Protection@ header.
    --
    -- You cannot specify a @ReportUri@ when @ModeBlock@ is @true@.
    --
    -- For more information about using a reporting URL, see
    -- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
    -- in the MDN Web Docs.
    ResponseHeadersPolicyXSSProtection -> Maybe Text
reportUri :: Prelude.Maybe Prelude.Text,
    -- | A Boolean that determines whether CloudFront overrides the
    -- @X-XSS-Protection@ HTTP response header received from the origin with
    -- the one specified in this response headers policy.
    ResponseHeadersPolicyXSSProtection -> Bool
override :: Prelude.Bool,
    -- | A Boolean that determines the value of the @X-XSS-Protection@ HTTP
    -- response header. When this setting is @true@, the value of the
    -- @X-XSS-Protection@ header is @1@. When this setting is @false@, the
    -- value of the @X-XSS-Protection@ header is @0@.
    --
    -- For more information about these settings, see
    -- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
    -- in the MDN Web Docs.
    ResponseHeadersPolicyXSSProtection -> Bool
protection :: Prelude.Bool
  }
  deriving (ResponseHeadersPolicyXSSProtection
-> ResponseHeadersPolicyXSSProtection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseHeadersPolicyXSSProtection
-> ResponseHeadersPolicyXSSProtection -> Bool
$c/= :: ResponseHeadersPolicyXSSProtection
-> ResponseHeadersPolicyXSSProtection -> Bool
== :: ResponseHeadersPolicyXSSProtection
-> ResponseHeadersPolicyXSSProtection -> Bool
$c== :: ResponseHeadersPolicyXSSProtection
-> ResponseHeadersPolicyXSSProtection -> Bool
Prelude.Eq, ReadPrec [ResponseHeadersPolicyXSSProtection]
ReadPrec ResponseHeadersPolicyXSSProtection
Int -> ReadS ResponseHeadersPolicyXSSProtection
ReadS [ResponseHeadersPolicyXSSProtection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResponseHeadersPolicyXSSProtection]
$creadListPrec :: ReadPrec [ResponseHeadersPolicyXSSProtection]
readPrec :: ReadPrec ResponseHeadersPolicyXSSProtection
$creadPrec :: ReadPrec ResponseHeadersPolicyXSSProtection
readList :: ReadS [ResponseHeadersPolicyXSSProtection]
$creadList :: ReadS [ResponseHeadersPolicyXSSProtection]
readsPrec :: Int -> ReadS ResponseHeadersPolicyXSSProtection
$creadsPrec :: Int -> ReadS ResponseHeadersPolicyXSSProtection
Prelude.Read, Int -> ResponseHeadersPolicyXSSProtection -> ShowS
[ResponseHeadersPolicyXSSProtection] -> ShowS
ResponseHeadersPolicyXSSProtection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseHeadersPolicyXSSProtection] -> ShowS
$cshowList :: [ResponseHeadersPolicyXSSProtection] -> ShowS
show :: ResponseHeadersPolicyXSSProtection -> String
$cshow :: ResponseHeadersPolicyXSSProtection -> String
showsPrec :: Int -> ResponseHeadersPolicyXSSProtection -> ShowS
$cshowsPrec :: Int -> ResponseHeadersPolicyXSSProtection -> ShowS
Prelude.Show, forall x.
Rep ResponseHeadersPolicyXSSProtection x
-> ResponseHeadersPolicyXSSProtection
forall x.
ResponseHeadersPolicyXSSProtection
-> Rep ResponseHeadersPolicyXSSProtection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResponseHeadersPolicyXSSProtection x
-> ResponseHeadersPolicyXSSProtection
$cfrom :: forall x.
ResponseHeadersPolicyXSSProtection
-> Rep ResponseHeadersPolicyXSSProtection x
Prelude.Generic)

-- |
-- Create a value of 'ResponseHeadersPolicyXSSProtection' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'modeBlock', 'responseHeadersPolicyXSSProtection_modeBlock' - A Boolean that determines whether CloudFront includes the @mode=block@
-- directive in the @X-XSS-Protection@ header.
--
-- For more information about this directive, see
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
-- in the MDN Web Docs.
--
-- 'reportUri', 'responseHeadersPolicyXSSProtection_reportUri' - A reporting URI, which CloudFront uses as the value of the @report@
-- directive in the @X-XSS-Protection@ header.
--
-- You cannot specify a @ReportUri@ when @ModeBlock@ is @true@.
--
-- For more information about using a reporting URL, see
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
-- in the MDN Web Docs.
--
-- 'override', 'responseHeadersPolicyXSSProtection_override' - A Boolean that determines whether CloudFront overrides the
-- @X-XSS-Protection@ HTTP response header received from the origin with
-- the one specified in this response headers policy.
--
-- 'protection', 'responseHeadersPolicyXSSProtection_protection' - A Boolean that determines the value of the @X-XSS-Protection@ HTTP
-- response header. When this setting is @true@, the value of the
-- @X-XSS-Protection@ header is @1@. When this setting is @false@, the
-- value of the @X-XSS-Protection@ header is @0@.
--
-- For more information about these settings, see
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
-- in the MDN Web Docs.
newResponseHeadersPolicyXSSProtection ::
  -- | 'override'
  Prelude.Bool ->
  -- | 'protection'
  Prelude.Bool ->
  ResponseHeadersPolicyXSSProtection
newResponseHeadersPolicyXSSProtection :: Bool -> Bool -> ResponseHeadersPolicyXSSProtection
newResponseHeadersPolicyXSSProtection
  Bool
pOverride_
  Bool
pProtection_ =
    ResponseHeadersPolicyXSSProtection'
      { $sel:modeBlock:ResponseHeadersPolicyXSSProtection' :: Maybe Bool
modeBlock =
          forall a. Maybe a
Prelude.Nothing,
        $sel:reportUri:ResponseHeadersPolicyXSSProtection' :: Maybe Text
reportUri = forall a. Maybe a
Prelude.Nothing,
        $sel:override:ResponseHeadersPolicyXSSProtection' :: Bool
override = Bool
pOverride_,
        $sel:protection:ResponseHeadersPolicyXSSProtection' :: Bool
protection = Bool
pProtection_
      }

-- | A Boolean that determines whether CloudFront includes the @mode=block@
-- directive in the @X-XSS-Protection@ header.
--
-- For more information about this directive, see
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
-- in the MDN Web Docs.
responseHeadersPolicyXSSProtection_modeBlock :: Lens.Lens' ResponseHeadersPolicyXSSProtection (Prelude.Maybe Prelude.Bool)
responseHeadersPolicyXSSProtection_modeBlock :: Lens' ResponseHeadersPolicyXSSProtection (Maybe Bool)
responseHeadersPolicyXSSProtection_modeBlock = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicyXSSProtection' {Maybe Bool
modeBlock :: Maybe Bool
$sel:modeBlock:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Maybe Bool
modeBlock} -> Maybe Bool
modeBlock) (\s :: ResponseHeadersPolicyXSSProtection
s@ResponseHeadersPolicyXSSProtection' {} Maybe Bool
a -> ResponseHeadersPolicyXSSProtection
s {$sel:modeBlock:ResponseHeadersPolicyXSSProtection' :: Maybe Bool
modeBlock = Maybe Bool
a} :: ResponseHeadersPolicyXSSProtection)

-- | A reporting URI, which CloudFront uses as the value of the @report@
-- directive in the @X-XSS-Protection@ header.
--
-- You cannot specify a @ReportUri@ when @ModeBlock@ is @true@.
--
-- For more information about using a reporting URL, see
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
-- in the MDN Web Docs.
responseHeadersPolicyXSSProtection_reportUri :: Lens.Lens' ResponseHeadersPolicyXSSProtection (Prelude.Maybe Prelude.Text)
responseHeadersPolicyXSSProtection_reportUri :: Lens' ResponseHeadersPolicyXSSProtection (Maybe Text)
responseHeadersPolicyXSSProtection_reportUri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicyXSSProtection' {Maybe Text
reportUri :: Maybe Text
$sel:reportUri:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Maybe Text
reportUri} -> Maybe Text
reportUri) (\s :: ResponseHeadersPolicyXSSProtection
s@ResponseHeadersPolicyXSSProtection' {} Maybe Text
a -> ResponseHeadersPolicyXSSProtection
s {$sel:reportUri:ResponseHeadersPolicyXSSProtection' :: Maybe Text
reportUri = Maybe Text
a} :: ResponseHeadersPolicyXSSProtection)

-- | A Boolean that determines whether CloudFront overrides the
-- @X-XSS-Protection@ HTTP response header received from the origin with
-- the one specified in this response headers policy.
responseHeadersPolicyXSSProtection_override :: Lens.Lens' ResponseHeadersPolicyXSSProtection Prelude.Bool
responseHeadersPolicyXSSProtection_override :: Lens' ResponseHeadersPolicyXSSProtection Bool
responseHeadersPolicyXSSProtection_override = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicyXSSProtection' {Bool
override :: Bool
$sel:override:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Bool
override} -> Bool
override) (\s :: ResponseHeadersPolicyXSSProtection
s@ResponseHeadersPolicyXSSProtection' {} Bool
a -> ResponseHeadersPolicyXSSProtection
s {$sel:override:ResponseHeadersPolicyXSSProtection' :: Bool
override = Bool
a} :: ResponseHeadersPolicyXSSProtection)

-- | A Boolean that determines the value of the @X-XSS-Protection@ HTTP
-- response header. When this setting is @true@, the value of the
-- @X-XSS-Protection@ header is @1@. When this setting is @false@, the
-- value of the @X-XSS-Protection@ header is @0@.
--
-- For more information about these settings, see
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection X-XSS-Protection>
-- in the MDN Web Docs.
responseHeadersPolicyXSSProtection_protection :: Lens.Lens' ResponseHeadersPolicyXSSProtection Prelude.Bool
responseHeadersPolicyXSSProtection_protection :: Lens' ResponseHeadersPolicyXSSProtection Bool
responseHeadersPolicyXSSProtection_protection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicyXSSProtection' {Bool
protection :: Bool
$sel:protection:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Bool
protection} -> Bool
protection) (\s :: ResponseHeadersPolicyXSSProtection
s@ResponseHeadersPolicyXSSProtection' {} Bool
a -> ResponseHeadersPolicyXSSProtection
s {$sel:protection:ResponseHeadersPolicyXSSProtection' :: Bool
protection = Bool
a} :: ResponseHeadersPolicyXSSProtection)

instance
  Data.FromXML
    ResponseHeadersPolicyXSSProtection
  where
  parseXML :: [Node] -> Either String ResponseHeadersPolicyXSSProtection
parseXML [Node]
x =
    Maybe Bool
-> Maybe Text -> Bool -> Bool -> ResponseHeadersPolicyXSSProtection
ResponseHeadersPolicyXSSProtection'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ModeBlock")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ReportUri")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Override")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Protection")

instance
  Prelude.Hashable
    ResponseHeadersPolicyXSSProtection
  where
  hashWithSalt :: Int -> ResponseHeadersPolicyXSSProtection -> Int
hashWithSalt
    Int
_salt
    ResponseHeadersPolicyXSSProtection' {Bool
Maybe Bool
Maybe Text
protection :: Bool
override :: Bool
reportUri :: Maybe Text
modeBlock :: Maybe Bool
$sel:protection:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Bool
$sel:override:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Bool
$sel:reportUri:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Maybe Text
$sel:modeBlock:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Maybe Bool
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
modeBlock
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reportUri
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
override
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
protection

instance
  Prelude.NFData
    ResponseHeadersPolicyXSSProtection
  where
  rnf :: ResponseHeadersPolicyXSSProtection -> ()
rnf ResponseHeadersPolicyXSSProtection' {Bool
Maybe Bool
Maybe Text
protection :: Bool
override :: Bool
reportUri :: Maybe Text
modeBlock :: Maybe Bool
$sel:protection:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Bool
$sel:override:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Bool
$sel:reportUri:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Maybe Text
$sel:modeBlock:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
modeBlock
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reportUri
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
override
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
protection

instance
  Data.ToXML
    ResponseHeadersPolicyXSSProtection
  where
  toXML :: ResponseHeadersPolicyXSSProtection -> XML
toXML ResponseHeadersPolicyXSSProtection' {Bool
Maybe Bool
Maybe Text
protection :: Bool
override :: Bool
reportUri :: Maybe Text
modeBlock :: Maybe Bool
$sel:protection:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Bool
$sel:override:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Bool
$sel:reportUri:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Maybe Text
$sel:modeBlock:ResponseHeadersPolicyXSSProtection' :: ResponseHeadersPolicyXSSProtection -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"ModeBlock" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Bool
modeBlock,
        Name
"ReportUri" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Text
reportUri,
        Name
"Override" forall a. ToXML a => Name -> a -> XML
Data.@= Bool
override,
        Name
"Protection" forall a. ToXML a => Name -> a -> XML
Data.@= Bool
protection
      ]