Skip to content

Commit

Permalink
Merge pull request #1027 from jkowens/patch-1
Browse files Browse the repository at this point in the history
Allow OmniAuthAuthenticityTokenProtection options to be configured
  • Loading branch information
BobbyMcWho committed Jan 16, 2021
2 parents 74e3efb + 52fea4e commit b55ad4c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/omniauth/authenticity_token_protection.rb
Expand Up @@ -18,6 +18,8 @@ def call!(env)
react env
end

alias_method :call, :call!

private

def deny(_env)
Expand Down
13 changes: 13 additions & 0 deletions spec/omniauth/strategy_spec.rb
Expand Up @@ -973,6 +973,19 @@ def make_env(path = '/auth/test', props = {})
end
end

context 'with custom allow_if proc' do
before do
OmniAuth.config.request_validation_phase = OmniAuth::AuthenticityTokenProtection.new(allow_if: ->(env) { true })
end

it 'allows a valid request' do
expect(strategy).to receive(:fail!).with('Request Phase', kind_of(StandardError))

post_env = make_env('/auth/test')
strategy.call(post_env)
end
end

after do
OmniAuth.config.request_validation_phase = nil
end
Expand Down

0 comments on commit b55ad4c

Please sign in to comment.