Skip to content

Commit

Permalink
Remove access_token from item payload (#966)
Browse files Browse the repository at this point in the history
* sw - remove access_token from item payload

* sw - update api stubs to validate with header access token instead of payload

* sw - file should no longer include access_token
  • Loading branch information
swangs committed Jun 9, 2020
1 parent fde3c08 commit 41a2008
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion lib/rollbar/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def payload
def build
data = build_data
self.payload = {
'access_token' => configuration.access_token,
'data' => data
}

Expand Down
1 change: 0 additions & 1 deletion lib/rollbar/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ def send_failsafe(message, exception, uuid = nil, host = nil)
}

failsafe_payload = {
'access_token' => configuration.access_token,
'data' => failsafe_data
}

Expand Down
3 changes: 1 addition & 2 deletions spec/rollbar/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
end

it 'should have the correct root-level keys' do
payload.keys.should match_array(['access_token', 'data'])
payload.keys.should match_array(['data'])
end

it 'should have the correct data keys' do
Expand Down Expand Up @@ -566,7 +566,6 @@
context 'with mutation in payload' do
let(:new_payload) do
{
'access_token' => configuration.access_token,
'data' => {
}
}
Expand Down
2 changes: 0 additions & 2 deletions spec/rollbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,6 @@ def backtrace
Rollbar.error(exception)

File.exist?(filepath).should eq(true)
File.read(filepath).should include test_access_token
File.delete(filepath)

Rollbar.configure do |config|
Expand All @@ -1293,7 +1292,6 @@ def backtrace
Rollbar.error(exception)

File.exist?(filepath).should eq(true)
File.read(filepath).should include test_access_token
File.delete(filepath)

Rollbar.configure do |config|
Expand Down
8 changes: 6 additions & 2 deletions spec/support/deploy_api/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ module DeployAPI
class Report < ::RollbarAPI
protected

def valid_data?(json, request)
!!json['environment'] && !!json['revision'] && super(json, request)
def authorized?(json, _request)
json['access_token'] != UNAUTHORIZED_ACCESS_TOKEN
end

def valid_data?(json, _request)
!!json['environment'] && !!json['revision'] && !!json['access_token']
end

def success_body(_json, _request)
Expand Down
8 changes: 4 additions & 4 deletions spec/support/rollbar_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def call(env)

protected

def authorized?(json, _request)
json['access_token'] != UNAUTHORIZED_ACCESS_TOKEN
def authorized?(_json, request)
request.env['HTTP_X_ROLLBAR_ACCESS_TOKEN'] != UNAUTHORIZED_ACCESS_TOKEN
end

def response_headers
Expand All @@ -26,8 +26,8 @@ def response_headers
}
end

def valid_data?(json, _request)
!!json['access_token']
def valid_data?(_json, request)
!!request.env['HTTP_X_ROLLBAR_ACCESS_TOKEN']
end

def unauthorized
Expand Down

0 comments on commit 41a2008

Please sign in to comment.