Skip to content

[Target 4.10.1] Support Content Security Policy#3443

Merged
compulim merged 23 commits intomicrosoft:masterfrom
compulim:feat-csp2
Sep 4, 2020
Merged

[Target 4.10.1] Support Content Security Policy#3443
compulim merged 23 commits intomicrosoft:masterfrom
compulim:feat-csp2

Conversation

@compulim
Copy link
Copy Markdown
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
Comment thread docs/CONTENT_SECURITY_POLICY.md Outdated
Comment thread docs/CONTENT_SECURITY_POLICY.md Outdated
Comment thread packages/component/src/Activity/SayAlt.js
@compulim compulim changed the title Support Content Security Policy [Target 4.10.1] Support Content Security Policy Sep 3, 2020
Comment thread packages/component/src/Composer.js Outdated
Copy link
Copy Markdown
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