DMARC interface: adkim + aspf.

This commit is contained in:
Philippe PITTOLI 2024-04-12 14:14:04 +02:00
parent aca29458a0
commit f21a7dd3cf
2 changed files with 27 additions and 2 deletions

View File

@ -18,7 +18,7 @@ module App.Page.Zone where
import Prelude (Unit, unit, void import Prelude (Unit, unit, void
, bind, pure , bind, pure
, not, comparing, discard, map, show, class Show , not, comparing, discard, map, show, class Show
, (+), (&&), ($), (/=), (<<<), (<>), (==), (>), (#), (=<<)) , (+), (&&), ($), (/=), (<<<), (<>), (==), (>), (#), (=<<), (-))
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
@ -183,6 +183,8 @@ data Action
| SPF_Modifier_Add | SPF_Modifier_Add
| DMARC_policy Int | DMARC_policy Int
| DMARC_adkim Int
| DMARC_aspf Int
| DKIM_hash_algo Int | DKIM_hash_algo Int
| DKIM_sign_algo Int | DKIM_sign_algo Int
@ -514,6 +516,9 @@ render state
(show state._currentRR.ttl) (show state._currentRR.ttl)
, Bulma.hr , Bulma.hr
, Bulma.selection_field "idDMARCPolicy" "Policy" DMARC_policy (map show DMARC.policies) (show state.dmarc.p) , Bulma.selection_field "idDMARCPolicy" "Policy" DMARC_policy (map show DMARC.policies) (show state.dmarc.p)
, Bulma.hr
, Bulma.selection_field "idDMARCadkim" "Consistency Policy for DKIM" DMARC_adkim DMARC.consistency_policies_txt_dkim (maybe "-" show state.dmarc.adkim)
, Bulma.selection_field "idDMARCaspf" "Consistency Policy for SPF" DMARC_aspf DMARC.consistency_policies_txt_spf (maybe "-" show state.dmarc.aspf)
] ]
display_domain_side = (if state._currentRR.name == (state._domain <> ".") then "" else "." <> state._domain) display_domain_side = (if state._currentRR.name == (state._domain <> ".") then "" else "." <> state._domain)
@ -766,6 +771,8 @@ handleAction = case _ of
handleAction $ ResetSPF handleAction $ ResetSPF
DMARC_policy v -> H.modify_ _ { dmarc { p = fromMaybe DMARC.None $ DMARC.policies A.!! v } } DMARC_policy v -> H.modify_ _ { dmarc { p = fromMaybe DMARC.None $ DMARC.policies A.!! v } }
DMARC_adkim v -> H.modify_ _ { dmarc { adkim = DMARC.consistency_policies A.!! (v - 1) } }
DMARC_aspf v -> H.modify_ _ { dmarc { aspf = DMARC.consistency_policies A.!! (v - 1) } }
DKIM_hash_algo v -> H.modify_ _ { dkim { h = DKIM.hash_algos A.!! v } } DKIM_hash_algo v -> H.modify_ _ { dkim { h = DKIM.hash_algos A.!! v } }
DKIM_sign_algo v -> H.modify_ _ { dkim { k = DKIM.sign_algos A.!! v } } DKIM_sign_algo v -> H.modify_ _ { dkim { k = DKIM.sign_algos A.!! v } }

View File

@ -145,6 +145,24 @@ data ConsistencyPolicy
-- | See https://publicsuffix.org/ for a list of organizational domains. -- | See https://publicsuffix.org/ for a list of organizational domains.
| Relaxed | Relaxed
consistency_policies :: Array ConsistencyPolicy
consistency_policies = [Strict, Relaxed]
consistency_policies_txt_spf :: Array String
consistency_policies_txt_spf
= [ "do not provide policy advice"
, "strict: \"From:\" and SPF domain must be identical"
, "relaxed: \"From:\" and SPF domain must be in the same organizational domain"
]
consistency_policies_txt_dkim :: Array String
consistency_policies_txt_dkim
= [ "do not provide policy advice"
, "strict: \"From:\" and DKIM domain (\"d:\") must be identical"
, "relaxed: \"From:\" and DKIM domain (\"d:\") must be in the same organizational domain"
]
-- | Codec for just encoding a single value of type `ConsistencyPolicy`. -- | Codec for just encoding a single value of type `ConsistencyPolicy`.
codecConsistencyPolicy :: CA.JsonCodec ConsistencyPolicy codecConsistencyPolicy :: CA.JsonCodec ConsistencyPolicy
codecConsistencyPolicy codecConsistencyPolicy