Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial State Is Sent Back To The SSC #1778

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

s0kil
Copy link
Collaborator

@s0kil s0kil commented Jul 27, 2023

My attempt at fixing issue #936

Send the Initial State To the Browser, And send it back when the component is initialized.

This requires the component to be an instance of FromJSON and ToJSON.

module Web.Component.PolicyEditor where

import Web.Component.Prelude
import Data.Aeson.TH

data PolicyEditor
    = PolicyEditor
          { maybeFacilityId :: Maybe (Id' "company_facilities")
          , maybePolicyId   :: Maybe (Id' "facility_policies")
          , modalOpen :: Bool
          }
    deriving (Data, Eq, Show)

$(deriveJSON defaultOptions 'PolicyEditor)

data PolicyEditorController
    = OpenModalAction
    | CloseModalAction
    deriving (Data, Eq, Show)

$(deriveSSC ''PolicyEditorController)

....

@s0kil s0kil requested a review from mpscholten July 27, 2023 05:54
@mpscholten
Copy link
Member

This would allow anyone to write any kind of component state which could be insecure. It might be better to cryptographically sign the initial state JSON and then check the signature in the component JSON decoder

@s0kil
Copy link
Collaborator Author

s0kil commented Jul 27, 2023

@mpscholten Is this a good approach in the first place, can't we save initial state in some ?context?

@mpscholten
Copy link
Member

Is this a good approach in the first place, can't we save initial state in some ?context?

Yes, this would be even better. AutoRefresh is working similiar to this. So that might be a good inspiration for designing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants