Pass username to OAuth2 login flow
Closes MBL-5463 Test Plan: GET login/oauth2/auth using the appropriate params for your canvas install + the new param of `unique_id={username}` Ensure that the username provided as a param is automatically populated into the username field of login form. Change-Id: I2d226953186cff2fecc5a19cbadd8627013481e8 Reviewed-on: https://gerrit.instructure.com/74208 QA-Review: Ben Kirato <benk@instructure.com> Reviewed-by: Cameron Sutter <csutter@instructure.com> Tested-by: Jenkins Product-Review: Peyton Craighill <pcraighill@instructure.com>
This commit is contained in:
parent
13e9402430
commit
c43cd8e5de
|
@ -78,7 +78,9 @@ class LoginController < ApplicationController
|
|||
end
|
||||
|
||||
unless flash[:delegated_message]
|
||||
return redirect_to url_for({ controller: "login/#{auth_type}", action: :new }.merge(params.slice(:id)))
|
||||
return redirect_to url_for({ controller: "login/#{auth_type}", action: :new }
|
||||
.merge(params.slice(:id))
|
||||
.merge(params.slice(:pseudonym_session)))
|
||||
end
|
||||
|
||||
# we had an error from an SSO - we need to show it
|
||||
|
|
|
@ -45,7 +45,9 @@ class Oauth2ProviderController < ApplicationController
|
|||
if @current_pseudonym && !params[:force_login]
|
||||
redirect_to Canvas::Oauth::Provider.confirmation_redirect(self, provider, @current_user)
|
||||
else
|
||||
redirect_to login_url(params.slice(:canvas_login, :pseudonym_session, :force_login, :authentication_provider))
|
||||
params["pseudonym_session"] = {"unique_id" => params[:unique_id]} if params.key?(:unique_id)
|
||||
redirect_to login_url(params.slice(:canvas_login, :pseudonym_session, :force_login,
|
||||
:authentication_provider, :pseudonym_session))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -77,6 +77,11 @@ wrong person in, as <a href="http://homakov.blogspot.com/2012/07/saferweb-most-c
|
|||
if a user already has an active Canvas web session, they will not be
|
||||
asked to re-enter their credentials.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="mono">unique_id<span class="label optional"></span></td>
|
||||
<td>Set to the user's username to be populated in the login form in the event
|
||||
that the user must authenticate.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -107,6 +107,12 @@ describe LoginController do
|
|||
get 'new', authentication_provider: ap2.id
|
||||
expect(response).to redirect_to(controller.url_for(controller: 'login/cas', action: :new, id: ap2.id))
|
||||
end
|
||||
|
||||
it "should pass pseudonym_session[unique_id] to redirect to populate username textbox" do
|
||||
get 'new', "pseudonym_session" => {"unique_id"=>"test"}
|
||||
expect(response).to redirect_to(
|
||||
controller.url_for(controller: 'login/canvas', action: :new)+'?pseudonym_session%5Bunique_id%5D=test')
|
||||
end
|
||||
end
|
||||
|
||||
describe "#logout" do
|
||||
|
|
|
@ -44,6 +44,12 @@ describe Oauth2ProviderController do
|
|||
expect(response).to redirect_to(login_url(:canvas_login => 1))
|
||||
end
|
||||
|
||||
it 'should pass pseudonym_session[unique_id] to login to populate username textbox' do
|
||||
get :auth, :client_id => key.id, :redirect_uri => Canvas::Oauth::Provider::OAUTH2_OOB_URI,
|
||||
"unique_id"=>"test", :force_login => true
|
||||
expect(response).to redirect_to(login_url+'?force_login=true&pseudonym_session%5Bunique_id%5D=test')
|
||||
end
|
||||
|
||||
context 'with a user logged in' do
|
||||
before :once do
|
||||
user_with_pseudonym(:active_all => 1, :password => 'qwerty')
|
||||
|
@ -93,6 +99,7 @@ describe Oauth2ProviderController do
|
|||
expect(response).to be_redirect
|
||||
expect(response.location).to match(/https:\/\/example.com/)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue