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

[Target 4.10.1] Support Content Security Policy #3443

Merged
merged 23 commits into from
Sep 4, 2020

Conversation

compulim
Copy link
Contributor

@compulim compulim commented Aug 31, 2020

Fixes #3393.

Changelog Entry

Breaking changes

  • To support Content Security Policy, glamor is being replaced by create-emotion. The CSS hash and rule name is being prefixed with webchat--css with a random value.

Changed

Samples

Description

This feature enables Web Chat to be embedded on a page with Content Security Policy enabled.

Design

Please refer to CONTENT_SECURITY_POLICY.md for design.

Specific Changes

  • Defined a baseline CSP
  • Added a new prop nonce
  • Moved from glamor to create-emotion
    • Updated CSS prefix from css-* to webchat--css-xxxxx-*
    • The CSS prefix will now have a randomized value to support multiple nonces
  • Inlined assets are now using blob: scheme, instead of data: scheme
  • Image attachments using data URI will be parsed and converted to URL with scheme of blob:
  • Web Worker detection is now done by loading a dummy Web Worker, instead of checking window.Worker
  • Bumped dependencies to support CSP
  • Added new internal hook useStyleToEmotionObject to convert from object style to emotion object
    • This is internal as we do not want to take emotion as part of our long-term dependency, this is also true for glamor and most of our dependencies
  • Added new internal hook useNonce for nonce prop
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Tests reviewed (coverage, legitimacy)

@compulim compulim changed the title [DRAFT] Support Content Security Policy Support Content Security Policy Sep 1, 2020
@compulim compulim changed the title Support Content Security Policy [DRAFT] Support Content Security Policy Sep 1, 2020
@corinagum corinagum self-assigned this Sep 1, 2020
@compulim compulim changed the title [DRAFT] Support Content Security Policy Support Content Security Policy Sep 1, 2020
@compulim compulim changed the title Support Content Security Policy [Target 4.10.1] Support Content Security Policy Sep 3, 2020
Copy link
Contributor

@corinagum corinagum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved pending a couple comments

@compulim compulim merged commit 2fede9e into microsoft:master Sep 4, 2020
@compulim compulim deleted the feat-csp2 branch September 4, 2020 06:28
@compulim compulim mentioned this pull request Sep 9, 2020
44 tasks
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.

Adding nonce to style to support Content Security Policy
2 participants