Skip to content

Commit

Permalink
Merge pull request #81 from dlindahl/feature/honor-skip-info
Browse files Browse the repository at this point in the history
Honor skip_info?
  • Loading branch information
tagliala authored Jan 10, 2024
2 parents 23e2ac8 + 52bf8ce commit 4c25eed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions lib/omniauth/strategies/cas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ class InvalidCASTicket < StandardError; end
end

extra do
prune!(
raw_info.delete_if { |k, _v| AUTH_HASH_SCHEMA_KEYS.include?(k) }
)
if skip_info?
{}
else
prune!(raw_info.dup.delete_if { |k, _v| AUTH_HASH_SCHEMA_KEYS.include?(k) })
end
end

uid do
Expand Down
20 changes: 20 additions & 0 deletions spec/omniauth/strategies/cas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,26 @@
expect(subject.hire_date).to eq '2004-07-13'
expect(subject.roles).to eq %w[senator lobbyist financier]
end

context 'when skip_info? is specified' do
let(:app) do
Rack::Builder.new do
use OmniAuth::Test::PhonySession
use MyCasProvider,
name: :cas,
host: 'cas.example.org',
ssl: false,
port: 8080,
uid_field: :employeeid,
skip_info: true
run ->(env) { [404, { 'Content-Type' => 'text/plain' }, [env.key?('omniauth.auth').to_s]] }
end.to_app
end

it 'does not include additional user attributes' do
expect(subject).to be_empty
end
end
end

context 'the credentials hash' do
Expand Down

0 comments on commit 4c25eed

Please sign in to comment.