Skip to content

Commit f2b0bc1

Browse files
committed
rename oauth scopes param to the standard scope
and it's space separated, not comma separated refs instructuregh-807 note that the old form - scopes - is still accepted for now Change-Id: I98e038125c3491abd54eb50c99d6efdf3e25acd7 Reviewed-on: https://gerrit.instructure.com/77412 Reviewed-by: Rob Orton <rob@instructure.com> Tested-by: Jenkins Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
1 parent 4992607 commit f2b0bc1

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

app/controllers/oauth2_provider_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def auth
3131
return render()
3232
end
3333

34-
scopes = params.fetch(:scopes, '').split(',')
34+
scopes = (params[:scope] || params[:scopes] || '').split(' ')
3535

3636
provider = Canvas::Oauth::Provider.new(params[:client_id], params[:redirect_uri], scopes, params[:purpose])
3737

doc/api/oauth.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ To manually generate a token for testing:
7979
<small><a href="#top">Back to Top</a></small>
8080

8181
Your application can rely on canvas for a user's identity. During step 1 of
82-
the web application flow below, specify the optional scopes parameter as
83-
scopes=/auth/userinfo. When the user is asked to grant your application
82+
the web application flow below, specify the optional scope parameter as
83+
scope=/auth/userinfo. When the user is asked to grant your application
8484
access in step 2 of the web application flow, they will also be given an
8585
option to remember their authorization. If they grant access and remember
8686
the authorization, Canvas will skip step 2 of the request flow for future requests.

doc/api/oauth_endpoints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ to do this opens your application to the possibility of logging the
5757
wrong person in, as <a href="http://homakov.blogspot.com/2012/07/saferweb-most-common-oauth2.html">described here</a>.</td>
5858
</tr>
5959
<tr>
60-
<td class="mono">scopes<span class="label optional"></span></td>
60+
<td class="mono">scope<span class="label optional"></span></td>
6161
<td>This can be used to specify what information the access token
6262
will provide access to. By default an access token will have access to
6363
all api calls that a user can make. The only other accepted value

spec/controllers/oauth2_provider_controller_spec.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,22 @@
104104

105105
it 'should redirect to the redirect uri if the user already has remember-me token' do
106106
@user.access_tokens.create!({:developer_key => key, :remember_access => true, :scopes => ['/auth/userinfo'], :purpose => nil})
107-
get :auth, client_id: key.id,
107+
get :auth,
108+
client_id: key.id,
109+
redirect_uri: 'https://example.com',
110+
response_type: 'code',
111+
scope: '/auth/userinfo'
112+
expect(response).to be_redirect
113+
expect(response.location).to match(/https:\/\/example.com/)
114+
end
115+
116+
it 'it accepts the deprecated name of scopes for scope param' do
117+
@user.access_tokens.create!({:developer_key => key, :remember_access => true, :scopes => ['/auth/userinfo'], :purpose => nil})
118+
get :auth,
119+
client_id: key.id,
108120
redirect_uri: 'https://example.com',
109121
response_type: 'code',
110-
scopes: '/auth/userinfo'
122+
scope: '/auth/userinfo'
111123
expect(response).to be_redirect
112124
expect(response.location).to match(/https:\/\/example.com/)
113125
end
@@ -126,7 +138,7 @@
126138
get :auth, client_id: key.id,
127139
redirect_uri: 'https://example.com',
128140
response_type: 'code',
129-
scopes: '/auth/userinfo'
141+
scope: '/auth/userinfo'
130142
expect(response).to be_redirect
131143
expect(response.location).to match(/https:\/\/example.com/)
132144
end

0 commit comments

Comments
 (0)