Don't show access tokens with internal developer keys
closes RECNVS-593 test plan: - access the user settings of an account which has communicated with instfs - verify that inst-fs is not included in the list of Åpproved Integrations [ci no-db-snapshot] Change-Id: Ic94dd9be5ec05b47c0053c87042571743530d81d Reviewed-on: https://gerrit.instructure.com/163390 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Jenkins QA-Review: Jonathan Featherstone <jfeatherstone@instructure.com> Product-Review: Michael Jasper <mjasper@instructure.com>
This commit is contained in:
parent
0bf9c33f78
commit
ed5c4e3a4c
|
@ -43,6 +43,7 @@ class AccessToken < ActiveRecord::Base
|
|||
|
||||
scope :active, -> { not_deleted.where("expires_at IS NULL OR expires_at>?", DateTime.now.utc) }
|
||||
scope :not_deleted, -> { where(:workflow_state => "active") }
|
||||
scope :visible, -> { joins(:developer_key).where('developer_keys.internal_service is not true') }
|
||||
|
||||
TOKEN_SIZE = 64
|
||||
|
||||
|
|
|
@ -457,7 +457,7 @@ TEXT
|
|||
<% end %>
|
||||
<h2><%= before_label(:'headers.approved_integrations', "Approved Integrations") %></h2>
|
||||
<div style="margin-<%= direction('left') %>: 20px;">
|
||||
<% if @user.access_tokens.empty? %>
|
||||
<% if @user.access_tokens.visible.empty? %>
|
||||
<div id="no_approved_integrations"><%= t(:no_approved_integrations, <<-TEXT)
|
||||
Third-party applications can request permission to access
|
||||
the Canvas site on your behalf. As you begin authorizing
|
||||
|
@ -465,7 +465,7 @@ TEXT
|
|||
TEXT
|
||||
%></div>
|
||||
<% end %>
|
||||
<div id="access_tokens_holder" style="<%= hidden if @user.access_tokens.empty? %>">
|
||||
<div id="access_tokens_holder" style="<%= hidden if @user.access_tokens.visible.empty? %>">
|
||||
<%= t(:approved_integrations, <<-TEXT)
|
||||
These are the third-party applications you have authorized
|
||||
to access the Canvas site on your behalf:
|
||||
|
@ -482,7 +482,7 @@ TEXT
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= render :partial => "access_token", :collection => @user.access_tokens %>
|
||||
<%= render :partial => "access_token", :collection => @user.access_tokens.visible %>
|
||||
<%= render :partial => "access_token" %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
class AddRedirectUrisToDeveloperKeys < ActiveRecord::Migration[4.2]
|
||||
tag :postdeploy
|
||||
tag :predeploy
|
||||
|
||||
def change
|
||||
add_column :developer_keys, :redirect_uris, :string, array: true, default: [], null: false
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# Copyright (C) 2018 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
class AddInternalServiceToDeveloperKeys < ActiveRecord::Migration[5.1]
|
||||
tag :predeploy
|
||||
|
||||
def change
|
||||
add_column :developer_keys, :internal_service, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
|
@ -167,6 +167,27 @@ describe AccessToken do
|
|||
end
|
||||
end
|
||||
|
||||
describe "Third party" do
|
||||
before do
|
||||
@trustedkey = DeveloperKey.new(internal_service: true)
|
||||
@trustedkey.save!
|
||||
|
||||
@untrustedkey = DeveloperKey.new()
|
||||
@untrustedkey.save!
|
||||
|
||||
@trusted_access_token = AccessToken.new({developer_key: @trustedkey})
|
||||
@trusted_access_token.save!
|
||||
|
||||
@third_party_access_token = AccessToken.new({developer_key: @untrustedkey})
|
||||
@third_party_access_token.save!
|
||||
end
|
||||
|
||||
it "only displays integrations from untrusted developer keys" do
|
||||
expect(AccessToken.visible.length).to eq 1
|
||||
expect(AccessToken.visible.first.id).to eq @third_party_access_token.id
|
||||
end
|
||||
end
|
||||
|
||||
describe "token scopes" do
|
||||
let_once(:token) do
|
||||
token = AccessToken.new
|
||||
|
|
Loading…
Reference in New Issue