canvas-embed 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +12 -0
- data/example/Gemfile +1 -1
- data/example/Gemfile.lock +2 -2
- data/example/README.md +1 -1
- data/example/app/controllers/application_controller.rb +9 -2
- data/example/config/routes.rb +2 -1
- data/example/log/development.log +1315 -0
- data/example/tmp/cache/bootsnap/compile-cache-iseq/26/420cf4a622d71b +0 -0
- data/example/tmp/cache/bootsnap/compile-cache-iseq/68/a73620fd7d4284 +0 -0
- data/example/tmp/cache/bootsnap/compile-cache-iseq/b2/d451a148d6d303 +0 -0
- data/example/tmp/cache/bootsnap/compile-cache-iseq/d8/fff5874ac0039e +0 -0
- data/example/tmp/cache/bootsnap/compile-cache-iseq/ee/02ad963145723a +0 -0
- data/example/tmp/cache/bootsnap/compile-cache-iseq/f3/1d1f40f0899932 +0 -0
- data/example/tmp/cache/bootsnap/load-path-cache +0 -0
- data/example/tmp/pids/server.pid +1 -1
- data/lib/canvas/embed/version.rb +1 -1
- data/lib/canvas/embed.rb +30 -2
- data/pkg/canvas-embed-0.1.5.gem +0 -0
- data/pkg/canvas-embed-0.1.6.gem +0 -0
- data/spec/canvas/embed_spec.rb +27 -6
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45b64ffaefba9ed0079b7d68ce049ea9b13f43e33b1b16af374eece5f2d602c2
|
4
|
+
data.tar.gz: 06712ec1051c757a7835ab7df4c6d47728a4bc99f6a0054d2d42b4fb606d162e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd3ee766aff62d4420fda59ab2e4a274a3cf28ebb00d5364b186c9476141fa350679db9506c45abab458c1f948d95409fa731300ff4c8700a982d3ae68d9992c
|
7
|
+
data.tar.gz: 8eb0765d2c8be6e8a5fd51e15637ad1a0c3692175a0ae3d89f1759ad093c40bf4d8503b2fbd1bedb41271c060503570d6726a1c30d1e88c46e41bb5728dcad3f
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -10,6 +10,18 @@ If any scopes are required by your charts that are not present in the scopes pay
|
|
10
10
|
|
11
11
|
You can view how this Gem is used in a sample rails app in the `example/` directory
|
12
12
|
|
13
|
+
# Usage
|
14
|
+
|
15
|
+
Add `gem 'canvas-embed'` to your Gemfile, then:
|
16
|
+
|
17
|
+
```
|
18
|
+
# key is the private key from Canvas
|
19
|
+
# scopes is the Hash of scopes to grant the user
|
20
|
+
# expiration_seconds is the duration in seconds for the token to be valid (default is one hour)
|
21
|
+
# user_id is an optional user identifier that will be used in Canvas' logging
|
22
|
+
Canvas::Embed.generate_embed_token(key, scopes, expiration_seconds, user_id)
|
23
|
+
```
|
24
|
+
|
13
25
|
# Running tests
|
14
26
|
|
15
27
|
```
|
data/example/Gemfile
CHANGED
data/example/Gemfile.lock
CHANGED
@@ -82,7 +82,7 @@ GEM
|
|
82
82
|
bootsnap (1.17.0)
|
83
83
|
msgpack (~> 1.2)
|
84
84
|
builder (3.2.4)
|
85
|
-
canvas-embed (0.1.
|
85
|
+
canvas-embed (0.1.6)
|
86
86
|
rbnacl (~> 7.1.1)
|
87
87
|
capybara (3.39.2)
|
88
88
|
addressable
|
@@ -251,7 +251,7 @@ PLATFORMS
|
|
251
251
|
|
252
252
|
DEPENDENCIES
|
253
253
|
bootsnap
|
254
|
-
canvas-embed (~> 0.1.
|
254
|
+
canvas-embed (~> 0.1.6)
|
255
255
|
capybara
|
256
256
|
debug
|
257
257
|
importmap-rails
|
data/example/README.md
CHANGED
@@ -10,7 +10,7 @@ After running `bundle install` you can start the Rails server with
|
|
10
10
|
CANVAS_SIGNING_KEY=[your signing key] bin/rails server
|
11
11
|
```
|
12
12
|
|
13
|
-
This serves a GET endpoint `
|
13
|
+
This serves a GET endpoint `generate_embed_token?scopes=[scopes]` where scopes are the scopes you want included in the generated token.
|
14
14
|
|
15
15
|
|
16
16
|
This endpoint is used in the [React component](https://github.com/canvas/embeds/tree/main/react) to view embedded Canvas charts as they will appear to your users.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class ApplicationController < ActionController::Base
|
4
|
-
def
|
4
|
+
def generate_embed_token
|
5
5
|
# this is the secret signing key from Canvas
|
6
6
|
key_hex = ENV['CANVAS_SIGNING_KEY']
|
7
7
|
# this should be updated to include the scopes needed for your charts and that are
|
@@ -11,7 +11,14 @@ class ApplicationController < ActionController::Base
|
|
11
11
|
rescue StandardError
|
12
12
|
return render json: { 'message' => 'Scopes were not valid JSON' }, status: 500
|
13
13
|
end
|
14
|
-
token = Canvas::Embed.
|
14
|
+
token = Canvas::Embed.generate_embed_token(key_hex, scopes, 7200, "usr_test123")
|
15
|
+
render json: { 'token' => token }
|
16
|
+
end
|
17
|
+
def generate_login_token
|
18
|
+
# this is the secret signing key from Canvas
|
19
|
+
key_hex = ENV['CANVAS_SIGNING_KEY']
|
20
|
+
email = params[:email]
|
21
|
+
token = Canvas::Embed.generate_login_token(key_hex, email)
|
15
22
|
render json: { 'token' => token }
|
16
23
|
end
|
17
24
|
end
|
data/example/config/routes.rb
CHANGED
@@ -6,7 +6,8 @@ Rails.application.routes.draw do
|
|
6
6
|
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
7
7
|
# Can be used by load balancers and uptime monitors to verify that the app is live.
|
8
8
|
get 'up' => 'rails/health#show', as: :rails_health_check
|
9
|
-
get '/
|
9
|
+
get '/generate_embed_token', to: 'application#generate_embed_token'
|
10
|
+
get '/generate_login_token', to: 'application#generate_login_token'
|
10
11
|
|
11
12
|
# Defines the root path route ("/")
|
12
13
|
# root "posts#index"
|