Commit Graph

36 Commits

Author SHA1 Message Date
Jacob Burroughs 7dcc507d0a Rubocop for ruby 3.1
[skip-stages=Flakey]

Change-Id: I6abefdfa9fed6dd4525c8786e93efa548b3710f2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/319603
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Isaac Moore <isaac.moore@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
Build-Review: Jacob Burroughs <jburroughs@instructure.com>
Migration-Review: Jacob Burroughs <jburroughs@instructure.com>
2023-06-06 16:44:26 +00:00
Jon Scheiding 36ff41e9b6 Remove environment variable that's no longer referenced
flag=none
closes MAT-617

test plan
- find an RCE and make sure it still works

Change-Id: Ieadc452d6a09cfed7d1fa94da1e4560e8d0139b3
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/284465
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jake Oeding <jake.oeding@instructure.com>
QA-Review: Jake Oeding <jake.oeding@instructure.com>
Product-Review: Jon Scheiding <jon.scheiding@instructure.com>
2022-02-04 18:51:31 +00:00
Weston Dransfield fe6de703f0 Restrict B&I visibility by user context permissions
closes MAT-624
flag=rce_buttons_and_icons

Test Plan:
1. Re-build Canvas webpack
2. Enable buttons & icons if needed
3. Enroll a teacher and a student in a course
4. Navigate to an RCE and verify the buttons
   and icons tool is present in the RCE toolbar
5. Act as the teacher in the same course
6. Repeat step 4
7. Act as a student in the same course
8. Navigate to an RCE and verify the buttons
   and icons tool is NOT present in the RCE
   toolbar

Change-Id: I7d35bc0f46fe591818c1c24bb4e97f1e38acb315
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/284352
Reviewed-by: Joe Hernandez <joe.hernandez@instructure.com>
QA-Review: Joe Hernandez <joe.hernandez@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: David Lyons <lyons@instructure.com>
2022-02-03 20:26:54 +00:00
Aaron Ogata 2f386d104a rename Canvas::DynamicSettings => DynamicSettings
Change-Id: Ia2c1754ce729d95bcbf194f6b31a5a2b36d42bbb
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/282694
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Charley Kline <ckline@instructure.com>
QA-Review: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
2022-01-12 21:54:51 +00:00
Cody Cutrer c2cba46851 RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation
[skip-stages=Flakey]

auto-corrected

Change-Id: I4a0145abfd50f126669b20f3deaeae8377bac24d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279535
Tested-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2021-11-25 14:03:06 +00:00
Cody Cutrer 0b8f78ffd0 RuboCop: Naming/RescuedExceptionsVariableName
[skip-stages=Flakey]

auto-corrected

Change-Id: Ie73290f10e1b9dbdd32d47513de0ce1b661c9199
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278625
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-18 02:24:17 +00:00
Jacob Burroughs 214014049f Add asymmetric encryption for service tokens
refs FOO-2410

test plan:
- in dynamic_settings.yml, add the following block:
```
store:
    canvas:
      services-jwt:
        # these are all the same JWK but with different kid
        # to generate a new key, run the following in a Canvas console:
        #
        # key = OpenSSL::PKey::RSA.generate(2048)
        # key.public_key.to_jwk(kid: Time.now.utc.iso8601).to_json
        jwk-past.json: "{\"kty\":\"RSA\",\"e\":\"AQAB\",\"n\":\"uX1MpfEMQCBUMcj0sBYI-iFaG5Nodp3C6OlN8uY60fa5zSBd83-iIL3n_qzZ8VCluuTLfB7rrV_tiX727XIEqQ\",\"kid\":\"2018-05-18T22:33:20Z_a\",\"d\":\"pYwR64x-LYFtA13iHIIeEvfPTws50ZutyGfpHN-kIZz3k-xVpun2Hgu0hVKZMxcZJ9DkG8UZPqD-zTDbCmCyLQ\",\"p\":\"6OQ2bi_oY5fE9KfQOcxkmNhxDnIKObKb6TVYqOOz2JM\",\"q\":\"y-UBef95njOrqMAxJH1QPds3ltYWr8QgGgccmcATH1M\",\"dp\":\"Ol_xkL7rZgNFt_lURRiJYpJmDDPjgkDVuafIeFTS4Ic\",\"dq\":\"RtzDY5wXr5TzrwWEztLCpYzfyAuF_PZj1cfs976apsM\",\"qi\":\"XA5wnwIrwe5MwXpaBijZsGhKJoypZProt47aVCtWtPE\"}"
        jwk-present.json: "{\"kty\":\"RSA\",\"e\":\"AQAB\",\"n\":\"uX1MpfEMQCBUMcj0sBYI-iFaG5Nodp3C6OlN8uY60fa5zSBd83-iIL3n_qzZ8VCluuTLfB7rrV_tiX727XIEqQ\",\"kid\":\"2018-06-18T22:33:20Z_b\",\"d\":\"pYwR64x-LYFtA13iHIIeEvfPTws50ZutyGfpHN-kIZz3k-xVpun2Hgu0hVKZMxcZJ9DkG8UZPqD-zTDbCmCyLQ\",\"p\":\"6OQ2bi_oY5fE9KfQOcxkmNhxDnIKObKb6TVYqOOz2JM\",\"q\":\"y-UBef95njOrqMAxJH1QPds3ltYWr8QgGgccmcATH1M\",\"dp\":\"Ol_xkL7rZgNFt_lURRiJYpJmDDPjgkDVuafIeFTS4Ic\",\"dq\":\"RtzDY5wXr5TzrwWEztLCpYzfyAuF_PZj1cfs976apsM\",\"qi\":\"XA5wnwIrwe5MwXpaBijZsGhKJoypZProt47aVCtWtPE\"}"
        jwk-future.json: "{\"kty\":\"RSA\",\"e\":\"AQAB\",\"n\":\"uX1MpfEMQCBUMcj0sBYI-iFaG5Nodp3C6OlN8uY60fa5zSBd83-iIL3n_qzZ8VCluuTLfB7rrV_tiX727XIEqQ\",\"kid\":\"2018-07-18T22:33:20Z_c\",\"d\":\"pYwR64x-LYFtA13iHIIeEvfPTws50ZutyGfpHN-kIZz3k-xVpun2Hgu0hVKZMxcZJ9DkG8UZPqD-zTDbCmCyLQ\",\"p\":\"6OQ2bi_oY5fE9KfQOcxkmNhxDnIKObKb6TVYqOOz2JM\",\"q\":\"y-UBef95njOrqMAxJH1QPds3ltYWr8QgGgccmcATH1M\",\"dp\":\"Ol_xkL7rZgNFt_lURRiJYpJmDDPjgkDVuafIeFTS4Ic\",\"dq\":\"RtzDY5wXr5TzrwWEztLCpYzfyAuF_PZj1cfs976apsM\",\"qi\":\"XA5wnwIrwe5MwXpaBijZsGhKJoypZProt47aVCtWtPE\"}"
```
- Ensure /internal/services/jwks loads correctly
- In console, ensure `CanvasSecurity::ServicesJwt.decrypt(Base64.decode64(CanvasSecurity::ServicesJwt.for_user('localhost', User.first)))`
and `CanvasSecurity::ServicesJwt.decrypt(Base64.decode64(CanvasSecurity::ServicesJwt.for_user('localhost', User.first, symmetric: true)))`
both work and produce sensible looking output

Change-Id: I13c6c35cc92ed12d03bf97e89e590614e11c6d47
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/275160
QA-Review: August Thornton <august@instructure.com>
Product-Review: August Thornton <august@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
Reviewed-by: Evan Battaglia <ebattaglia@instructure.com>
2021-10-06 15:11:06 +00:00
Cody Cutrer f5d0cc64bc add failsafe option for DynamicSettings
so that we're not re-implementing it at multiple callsites

also remove unused error classes

Change-Id: I938d705729f2208532b4522eddbc8edfa4f2031f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/269561
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-08-02 18:27:59 +00:00
August Thornton 2c77683ac0 remove granular permissions for course files FF
closes FOO-1766
flag = none

[fsc-max-nodes=18]
[fsc-timeout=30]

Test Plan:
  - Run the migration and make sure there are no errors
  - Some things to check:
    * How it acts as a teacher, student, and public user
      in course files/folders and personal files/folders
      with the various settings above toggled to different states
    * How it acts as a teacher, student, and public user
      in discussions, modules, content migrations/import/exports
      (RCE should behave similarly throughout the site)
    * Should only be able to upload or add folders if the
      Course Files - add permission is enabled for the user's role
    * Should only be able to manage file access, usage rights, move,
      or rename course files/folders if the Course Files -
      edit permission is enabled for the user's role
      • Check Toolbar header at the top of Course files
      • Check Cog (hamburger menu) to the right of each file/folder
      • Check Usage Rights Indicator under usage rights column
        that can be found in course and group file pages. This can
        be enabled under course settings if not available
    * Should only be able to delete course files/folders if the
      Course Files - delete permission is enabled for the user's role
    * Any given user/role should have full access to their respective
      personal files/folders regardless of granted permissions. The
      same also applies to a group context with some caveats
      • Should not be able to modify file access in a group context
      • Should not be able to modify usage rights in personal files
    * A student enrollment not granted any file permissions (the default)
      should only be able to _view_ and _download_ files unless granted
      additional access from an authorizing role
    * REST API works as expected
    * UI works as expected with no additional javascript errors
Change-Id: I5e7f717494d658e6c8ec9be8a8039015afcebc63
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/262775
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Ahmad Amireh <ahmad@instructure.com>
QA-Review: Ahmad Amireh <ahmad@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2021-07-16 15:31:37 +00:00
Jacob Burroughs bca8bd4629 Migrate to diplomat
Change-Id: I82363dedbd2397830a9beadf33b1cc59123136c8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/263429
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
2021-04-29 17:00:51 +00:00
August Thornton 66464cbbf6 add UI updates to granular permissions for course files
closes FOO-1501
refs FOO-130
flag = granular_permissions_course_files
[fsc-max-nodes=18]

Test Plan:
 • see test plan outlined in base commit: g/253777

Change-Id: I33984062fd236348d39262395e5f51335e327ed9
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/256914
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Michael Ziwisky <mziwisky@instructure.com>
Reviewed-by: Charley Kline <ckline@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: August Thornton <august@instructure.com>
2021-01-29 16:01:02 +00:00
August Thornton 940f47ec07 add granular permissions for course files
Note: we'll want to re-run the data fix-up when we're ready to turn
on the feature flag permanently; in hopes to capture any differences
made to course files permissions between now and then.

Modified the files_controller quota and api_quota permission checks
to make them more lenient in regards to accepting any or all of the
files permissions role overrides. This allows legacy grouping and
new granularized files permissions to live in harmony and be modified
without causing unauthorized errors on the quota resource.

This commit will cover the backend permissions required to granularize
files / folders permission calls, however there will be a follow-up
ps to clean up the course file page to hide elements the user might
not be authorized to use.

closes FOO-130
refs FOO-1501
flag = granular_permissions_course_files
[fsc-max-nodes=18]
[fsc-timeout=30]

Test Plan:
  - Run the migration and make sure there are no errors
  - With the granular_permissions_course_files FF turned off,
    course sections and REST API should work the same with this patch
    set checked out as it does in beta/production
  - Some things to check:
    * How it acts as a teacher, student, and public user
      in course files/folders and personal files/folders
      with the various settings above toggled to different states
    * How it acts as a teacher, student, and public user
      in discussions, modules, content migrations/import/exports
      (RCE should behave similarly throughout the site)
  - With the granular_permissions_course_files feature flag turned on
    course files/folders and REST API should work as expected. The same
    list checked above should be done so again, but this time:
    * Should only be able to upload or add folders if the
      Course Files - add permission is enabled for the user's role
    * Should only be able to manage file access, usage rights, move,
      or rename course files/folders if the Course Files -
      edit permission is enabled for the user's role
      • Check Toolbar header at the top of Course files
      • Check Cog (hamburger menu) to the right of each file/folder
      • Check Usage Rights Indicator under usage rights column
        that can be found in course and group file pages. This can
        be enabled under course settings if not available
    * Should only be able to delete course files/folders if the
      Course Files - delete permission is enabled for the user's role
    * Any given user/role should have full access to their respective
      personal files/folders regardless of granted permissions. The
      same also applies to a group context with some caveats
      • Should not be able to modify file access in a group context
      • Should not be able to modify usage rights in personal files
    * A student enrollment not granted any file permissions (the default)
      should only be able to _view_ and _download_ files unless granted
      additional access from an authorizing role
    * REST API works as expected
    * UI works as expected with no additional javascript errors

Change-Id: Ieb2d10915c274959e8da4c623f7aba11d3540c2b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/253777
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: August Thornton <august@instructure.com>
Reviewed-by: Michael Ziwisky <mziwisky@instructure.com>
2021-01-27 17:02:38 +00:00
Cody Cutrer 06763dd519 add # frozen_string_literal: true for lib
Change-Id: I59b751cac52367a89e03f572477f0cf1d607b405
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251155
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-27 20:49:50 +00:00
Ryan Shaw 4f97c6df56 remove all the legacy RCE code
closes: CORE-2588 CORE-2591

This completely removes the legacy RCE codepath. So you will need to
Have an https://github.com/instructure/canvas-rce-api running to use
sidebar in any Rich Content Editors.

Test plan:
* smoke test to make sure that the editor and sidebar work as it did
  When you had the RCS feature flag on.
* there should not be any more settings or feature flags around turning
  on the RCS service

Change-Id: I1c3e7f5a45eed5e010d8e425ae561e45f739fd3a
Reviewed-on: https://gerrit.instructure.com/186525
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
2019-04-04 18:19:12 +00:00
Brent Burgoyne 636e769a04 make rcs handle missing secrets more gracefully
closes CORE-1891

test plan:
- put null encryption and/or signing secretys in consul (or
  dynamic_settings.yml)
- go to a page with an rce
- should not 500
- sidebar requests should 401

Change-Id: I8fd169c74df06fc5d5e04684a95e41023ea23c61
Reviewed-on: https://gerrit.instructure.com/164501
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2018-09-17 03:39:00 +00:00
Brent Burgoyne d78e11064a make rcs enabled setting enable all risk levels
refs CORE-50

test plan:
- in rails console run:
    Setting.set('rich_content_service_enabled', 'true')
- start canvas (or restart if already running)
- turn of the rcs feature flag if on
- all editors should be using RCS

Change-Id: I9912b14bc92182716921acf6a5c2ffa51e1d1e23
Reviewed-on: https://gerrit.instructure.com/148757
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2018-05-07 16:03:24 +00:00
brian kirkby e8787b677f don't load mathjax on pages with equation editor img
fixes CNVS-40065
fixes CORE-363

test plan:
- create a page with both MathML and an equation editor image
  - add an equation through eq ed
  - go into html view and add: '<p><math><mi>π</mi><msup><mi>r</mi><mn>2</mn></msup></math></p>'
- while viewing the page after saving, open the console
  and verify that MathJax is not defined
- also verify in chrome that the pir^2 equation above is not
  prettified

Change-Id: I49a83ad8836ce365ccb0ec09f5841bc5a8c91d7d
Reviewed-on: https://gerrit.instructure.com/130362
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Tested-by: Jenkins
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Nathan Rogowski <nathan@instructure.com>
2017-11-07 18:02:22 +00:00
Brent Burgoyne 7b254f1ad6 stop replacing iframes with placeholders
this also fixes a script error that would prevent saving that was
caused be a conflict between the iframe placeholder and the tinymce
media plugin.

closes CORE-379, closes CORE-380

test plan:
- make sure rcs feature flag is enabled
- create/edit a wiki page
- insert a table
- insert a youtube video in the table with the media toolbar button
  (or any other iframe)
- insert a unorderd list
- insert an iframe inside a list item
- both iframes should show a live preview
- save the wiki page
- should save without errors

Change-Id: I4eaf4fff0d534577f16dae44546c29fa369f5356
Reviewed-on: https://gerrit.instructure.com/131360
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2017-11-01 20:08:04 +00:00
Cody Cutrer 7197e44389 refactor and impove DynamicSettings
closes CNVS-35834

 * allow specifying tree, service, and cluster for consul stuff
 * check multiple consul keys for each setting (cluster, env, region, global)

test plan:
 * an existing consul environment still works

Change-Id: I48e8fadeac2e140973bfc4b41c1cfb386532d15c
Reviewed-on: https://gerrit.instructure.com/125271
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2017-09-12 22:34:21 +00:00
Brent Burgoyne bdd84843ca put rich content service behind setting
until rcs is open sourced we don't want it enabled by default for
open source users.

closes CNVS-38092

test plan:
- disable rcs feature flag
- rcs should be off everywhere
- from the rails console run:
  - Setting.set('rich_content_service_enabled', 'true')
- send SIGHUP to your rails process(es)
- rcs should be on for eportfolios and wiki pages
- enable rcs feature flag
- rcs should be on everywhere

Change-Id: Ibca84b7183dd0344b73433024b47e9948cbab3e8
Reviewed-on: https://gerrit.instructure.com/118223
Tested-by: Jenkins
Reviewed-by: brian kirkby <bkirkby@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2017-07-10 19:24:46 +00:00
Brent Burgoyne 179bf7c5fc change rcs feature flag text, remove first 2 flags
the first two rcs flags have been enabled for all hosted accounts
for a long time. we are changing the lable of the 3rd flag and removing the
first two to provide better clarity as we enable the 3rd flag for
accounts.

closes CNVS-37261

test plan:
- go to the feature flags page for an account
  - there should only be one rcs flag with an updated message
- ensure that flag is disabled
- editing wiki pages should still have the new sidebar
- high risk area (i.e. quizzes, assignments) should not have the new
  sidebar
- enable the flag
- all editors should be using rcs with the new sidebar

Change-Id: I689eb9ebaf4d3a5fc111c231d13861cc28ae5d87
Reviewed-on: https://gerrit.instructure.com/116542
Tested-by: Jenkins
Reviewed-by: brian kirkby <bkirkby@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2017-06-27 18:39:16 +00:00
brian kirkby 6588307005 selenium tests for using canvas-rce with canvas-lms
identified which selenium tests use tinymce, then copy those tests to a
separate directory, modify them to use canvas-rce. was a whole process that is
documented here: http://bit.ly/2s25jVD

closes CNVS-36164

test plan:
- run selenium tests
- see they pass
- esp. in jenkins

Change-Id: Iddce2d4e3f8fc29c319c4f0496a577eaa01519ea
Reviewed-on: https://gerrit.instructure.com/113835
Tested-by: Jenkins
Product-Review: brian kirkby <bkirkby@instructure.com>
Reviewed-by: Tyler Pickett <tpickett@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
2017-06-13 16:29:49 +00:00
Tyler Pickett 7b45e0fd24 Add environment prefix to consul keys.
Since some environments share a consul datacenter we need to be able to
differentiate configurations.

Fixes: CNVS-34341

Test Plan:
- Nothing uses this yet but we need to make sure we haven't broken JWT
  secrets, the RCE, and Address Book.

Change-Id: I496a8f7d2cafd02c3177a28b348679e552965c0d
Reviewed-on: https://gerrit.instructure.com/99650
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Tyler Pickett <tpickett@instructure.com>
2017-05-05 19:39:16 +00:00
Landon Wilkins e26843ff95 da licença part 34
add consistent license headers to all source files
(ruby, coffeescript, javascript)

except for vendor files

Change-Id: Ic6b3be7861a2c91d76889c1740f964e401638e04
Reviewed-on: https://gerrit.instructure.com/110061
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-04-27 22:00:30 +00:00
Tyler Pickett f0214f0923 Switch to Imperium gem and update Consul container.
Also, make Consul container accessible from the host.

Fixes: CNVS-35831
Refs: CNVS-34341, CNVS-32864

Test Plan:
- Smoke test RCS and Canvas running together to make sure they still
  play nice.

Change-Id: I418d54a176677b1df8ec42a009752807908a847c
Reviewed-on: https://gerrit.instructure.com/99443
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Tyler Pickett <tpickett@instructure.com>
2017-04-07 16:59:01 +00:00
Brent Burgoyne fe4ac3e8eb add ui jwt workflow that includes high contrast
define a new workflow inteded to be used by any service that needs to
render a ui. this workflow includes state indicating if high contrast
styles should be used.

refs CNVS-31909, closes CNVS-31983

test plan:
- enable high contrast
- make sure rcs is enabled
- go to view with rce sidebar
- get the jwt from Authoriation header of requests to rcs
  - don't inclued "Bearer "
- open the canvas console, run:
  Canvas::Security.decrypt_services_jwt(
    Canvas::Security.base64_decode('<token here>')
  )
- make suer the token inclues use_high_contrast: true
- disable high contrast
- repeat, but  use_high_contrast should be false in the token

Change-Id: I8752ad534928081d2e4b8e8d748f8dd9897222a2
Reviewed-on: https://gerrit.instructure.com/90452
Tested-by: Jenkins
Reviewed-by: John Corrigan <jcorrigan@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2016-09-23 22:12:32 +00:00
Brent Burgoyne 634bca8777 add workflow and additional state to jwt for rcs
for a given workflow, services consuming canvas jwts may need access
to additional state (feature flags, permissions, etc). this commit
introduces the ability to to define state requirements for a jwt
based on its workflows, context and user.

the concept of jwt workflow has been made plural and it expects it to
be an array of workflows. a token for one service may need to be used
in multiple workflows (i.e. a quiz token may need to work as a rich
content token as well).

this commit defines the :rich_content workflow which includes upload
and usage rights information.

tokens also include context type and id. since the workflow state may
be specific to the context, this provides a way for the service to
validate that the token is being used in the correct context.

code that generates conditional-release tokens has been updated to use
the workflows array. this won't break anything becuase, even though it
is including in the token, it is not being validated yet. future
validations will check for inclusion in the array.

refs CNVS-30966, refs CNVS-32094

test plan:
- launch a page with the rich content service side bar
- ensure the request to the proxy don't return 401 status codes
- a test plan for the consuption of the new data in the token will
  come with a seperate RCS commit

Change-Id: I9e643995cb98547664f721a9b5d8c9441010eea9
Reviewed-on: https://gerrit.instructure.com/89012
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2016-09-22 02:47:17 +00:00
Ethan Vizitei 23fcced026 let canvas decide if RCE user can upload files
fixes CNVS-28429

TEST PLAN:
 1) load up RCE with canvas
 2) on image upload sidebar tab, should be allowed to open the form
    to upload an image

Change-Id: I752b202f2ded23ff1d8a1fb55470773963145186
Reviewed-on: https://gerrit.instructure.com/76173
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2016-04-06 15:18:32 +00:00
Ethan Vizitei 447336058e provide a JWT masquerading user slot
fixes CNVS-28330

TEST PLAN:
  1) generate a JWT with the "for_user" method
  2) if a masquerading user is provided, it should be included in the
body
  3) eventually, using a wrapping service should be able to preserve
     audit trail across an external api call with JWT

Change-Id: Ic10bcc4ac2e8b4222005d765cec2df3dd4740f64
Reviewed-on: https://gerrit.instructure.com/75741
Tested-by: Jenkins
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2016-04-05 16:52:19 +00:00
Jacob Fugal 79861cf20d clean up RCE abstraction layer and service sidebar
refs CNVS-26704, CNVS-26707

RichContentEditor and RceCommandShim:

* move risk level management all to the server side; just one flag in JS
  is set contextually in the server response based on server chosen risk
  level for the page

* flatten the RichContentEditor and RceCommandShim modules to singleton
  method collections, rather than instances

* add RceCommandShim.focus and .destroy methods that more gracefully
  divide the implementations vs. just using send(target, 'focus') or
  send(target, 'destroy')

Editor Loading and Focus

* replace attachSidebarTo calls -- which always (see one exception
  below) paired with a loadNewEditor call -- are replaced with the
  focus:true option to loadNewEditor. when on, the editor is explicitly
  focused after load; it no longer turns on tinymce auto_focus

* on internal tinymce events that trigger 'editor_box_focus' events,
  explicitly focus the editor. this was an attachSidebarTo call (the
  exception) only registered for quizzes, but now more generally.

Editor Destruction

* replace callOnRCE(target, 'destroy') and target._removeEditor() calls
  with new RichContentEditor.destroyRCE(target). destroys the editor as
  before, but does so through new RceCommandShim.destroy and also hides
  sidebar (so no need for explicit hideSidebar calls, which only ever
  accompanied editor destruction)

Sidebar

* add remoteSidebar.show() and remoteSidebar.hide() polyfills

* separate sidebar abstraction into Sidebar module. public interface is
  still through RichContentEditor: initSidebar calls Sidebar.init and
  show/hide are only called from RichContentEditor implementation in
  response to editor focus and destruction.

* allow registering callbacks during initSidebar for when the sidebar is
  shown/hidden. so the desired action doesn't have to be coupled with
  individual calls to loadNewEditor and destroyRCE.

* ensure initSidebar, when present, precedes loadNewEditor. so if
  there's going to be a sidebar, it's initialized before the editor load
  tries to show it.

* add initSidebar calls to discussions/Reply.coffee and
  editor/EditorToggle.coffee so that they get automatic focus, sidebar
  show on editor load, and sidebar hide on editor destruction,
  previously provided by util/wikiSidebarWithMultipleEditors.coffee.

* cache wikiSidebar elements as soon as initSidebar is called, rather
  than waiting for domready, so that initSidebar doesn't have to be in a
  domready itself.

Miscellaneous

* replace calls of target._justGetCode() and target._setContentCode(...)
  with RichContentEditor.callOnRCE(target, 'get_code') and
  RichContentEditor.callonRCE(target, 'set_code', ...), respectively

* remove a dead legacy bundle and d dead module only used by that dead
  bundle

* clean up dependencies to remove unnecessary references to wikiSidebar,
  compiled/tinymce, and tinymce.editor_box outside of the abstraction
  layer or legacy-only code.

* fix idGenerator fragile spec bug

test-plan:
  there should not be significant changes in _what_ the RCE or sidebar
  does. but significant changes in _how_. so no new features to test,
  but a thorough regression on RCE and sidebar behaviors is probably in
  order (sorry)

Change-Id: I4e0cbcb3dcb28152750bf9267d795a179822a601
Reviewed-on: https://gerrit.instructure.com/75469
Tested-by: Jenkins
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2016-03-30 18:03:24 +00:00
Jacob Fugal 78258f420a include JWT in js ENV for RCS sidebar
test-plan:
 - visit an RCE page
 - ENV.JWT in the web console should be set

Change-Id: I63e5d6750732a4a9ff0fed04e915b60e85c9f58b
Reviewed-on: https://gerrit.instructure.com/74789
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2016-03-30 18:03:11 +00:00
Ethan Vizitei 6889c3fef1 Syllabus RCE
closes CNVS-27638
closes CNVS-27733

Start RCE service integration with granular
feature flags for sidebar areas

Also fix some items in the RCE abstraction
layer for graceful fallback, and refactors
abstraction layer for injecting context
both for testing and for use cases
that perform the same wrapper work
over and over.

TEST PLAN:
 1) regression test creating a syllabus (should not break)
 2) with RCE service in the mix and the RICH_CONTENT_SIDEBAR_ENABLED
    flag on (the medium risk flag), side bar should show replaced
    by dummy sidebar from RCE service
 3) note that we do not expect the sidebar to be functional yet
    with the service, this is just making sure we can flip the
    switch, and didn't break syllabus in the process

Change-Id: I775669214b2541b037daf0c55caa00e452487927
Reviewed-on: https://gerrit.instructure.com/73426
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2016-03-08 17:00:31 +00:00
Ethan Vizitei 2999576bdc RCE resiliant to consul failure
closes CNVS-27666

this stops us from getting a page error in cases
where consul is suddenly gone and we don't have a
cached value for a CDN endpoint.

Users will get an error in their js console,
and the textarea will display with no editor chrome.

TEST PLAN:
 1) point your consul.yml to a fake host
 2) with the feature flag for RCE on, go to eportfolios
    and try to edit one
 3) you should still be able to play with the form, even though
    you won't have an editor

Change-Id: Ia5a1e4b9e243e2c10cdc12726a26f6a0eb2e0d1f
Reviewed-on: https://gerrit.instructure.com/73545
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2016-03-04 18:48:34 +00:00
Ethan Vizitei c9eae629ed consul caching
closes CNVS-27597

We need to not slam consul for rarely changing data.
the '#find' method still gets the value from consul everytime.
Cache can be infinite or with timeout.

TEST PLAN:
 1) have some data in consul for what the signing secret is for canvas
 2) Make sure to query it (Canvas::Security::ServicesJwt.signing_secret)
 3) change the consul data
 4) query it again, it should not have updated
 5) send a SIGHUP
 6) query it again, it should have changed

Change-Id: I5b923b8e44ab90692e87969c494a7c65fafcad72
Reviewed-on: https://gerrit.instructure.com/73198
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins
Reviewed-by: David Adams <dadams@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2016-03-01 21:34:32 +00:00
Ethan Vizitei effe2317b6 gradual feature flags for rce service
closes CNVS-27212

Gives us the ability to turn on RCE integration
for one category of use case at a time rather than all
at once

TEST PLAN:
 1) nothing uses the higher level feature flags yet
 2) make sure you can enable and disable the new feature flags?
Change-Id: I187f2da931a1374ff0893000849a6dbef3332c0b
Reviewed-on: https://gerrit.instructure.com/73065
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2016-02-29 18:07:00 +00:00
Ethan Vizitei be9244a47c add feature flag and dynamic config for RCE service
refs CNVS-24816

create the feature flag and expose it in
the Eportfolios controller

Add a consul docker container to docker-compose.yml,
and a class for consuming settings in consul.

Also, add the ability to init config values
into consul from the consul.yml file

TEST PLAN:
1) edit your consul.yml to look kinda like this:

development:
  host: consul
  port: 8500
  ssl: false
  init_values:
    rich-content-service:
      app-host: rce.docker
      cdn-host: rce.docker

2) go to edit an eportfolio as a logged in user
3) check in js console "ENV.RICH_CONTENT_SERVICE_ENABLED"
4) should be "true" or "false" depending on the feature
flag state for that user's root account
5) with the feature flag on, refresh and check the env
6) should have values in the env for
RICH_CONTENT_APP_HOST and RICH_CONTENT_CDN_HOST

Change-Id: Ic138e24416b2aadd965ce4811d3c56538de391bc
Reviewed-on: https://gerrit.instructure.com/66614
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2015-12-02 20:32:42 +00:00