Skip to content

Commit

Permalink
Upgrade from OmniAuth 1 to OmniAuth 2.
Browse files Browse the repository at this point in the history
Update company info.
Other tiny fixes.
  • Loading branch information
5andi5 committed Jun 26, 2023
1 parent 068d4f7 commit 27700b6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ rvm:
- 2.2.6
- 2.3.3
- 2.4.1
- 3.2.2
script: bundle exec rspec
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
Omniauth strategy for using Swedbank as an authentication service provider.

[![Gem Version](https://badge.fury.io/rb/omniauth-swedbank.png)](http://badge.fury.io/rb/omniauth-swedbank)
[![Build Status](https://travis-ci.org/mak-it/omniauth-swedbank.svg?branch=master)](https://travis-ci.org/mak-it/omniauth-swedbank)
[![Build Status](https://travis-ci.org/mitigate-dev/omniauth-swedbank.svg?branch=master)](https://travis-ci.org/mitigate-dev/omniauth-swedbank)

Supported Ruby versions: 2.2+

## Related projects

- [omniauth-citadele](https://github.com/mak-it/omniauth-citadele) - strategy for authenticating with Citadele
- [omniauth-dnb](https://github.com/mak-it/omniauth-dnb) - strategy for authenticating with DNB
- [omniauth-nordea](https://github.com/mak-it/omniauth-nordea) - strategy for authenticating with Nordea
- [omniauth-seb-elink](https://github.com/mak-it/omniauth-seb-elink) - strategy for authenticating with SEB
- [omniauth-citadele](https://github.com/mitigate-dev/omniauth-citadele) - strategy for authenticating with Citadele
- [omniauth-dnb](https://github.com/mitigate-dev/omniauth-dnb) - strategy for authenticating with DNB
- [omniauth-nordea](https://github.com/mitigate-dev/omniauth-nordea) - strategy for authenticating with Nordea
- [omniauth-seb-elink](https://github.com/mitigate-dev/omniauth-seb-elink) - strategy for authenticating with SEB

## Installation

Add this line to your application's Gemfile:
Add these lines to your application's Gemfile (omniauth-rails_csrf_protection is required if using Rails):

gem 'omniauth-rails_csrf_protection'
gem 'omniauth-swedbank'

And then execute:
Expand All @@ -26,7 +27,7 @@ And then execute:

Or install it yourself as:

$ gem install omniauth-swedbank
$ gem install omniauth-rails_csrf_protection omniauth-swedbank

## Usage

Expand Down
2 changes: 1 addition & 1 deletion lib/omniauth/strategies/swedbank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def request_phase
'VK_LANG' => 'LAT',
'VK_ENCODING' => 'UTF-8'
}.each do |name, val|
form.html "<input type=\"hidden\" name=\"#{name}\" value=\"#{val}\" />"
form.html "<input type=\"hidden\" name=\"#{name}\" value=\"#{escape(val)}\" />"
end

form.button I18n.t('omniauth.swedbank.click_here_if_not_redirected')
Expand Down
17 changes: 9 additions & 8 deletions omniauth-swedbank.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ require 'omniauth/swedbank/version'
Gem::Specification.new do |spec|
spec.name = 'omniauth-swedbank'
spec.version = Omniauth::Swedbank::VERSION
spec.authors = ['MAK IT', 'Jānis Kiršteins', 'Kristaps Ērglis']
spec.email = ['admin@makit.lv', '[email protected]', '[email protected]' ]
spec.authors = ['Mitigate', 'Jānis Kiršteins', 'Kristaps Ērglis']
spec.email = ['admin@mitigate.dev', '[email protected]', '[email protected]' ]
spec.description = %q{OmniAuth strategy for Swedbank Banklink}
spec.summary = %q{OmniAuth strategy for Swedbank Banklink}
spec.homepage = 'https://github.com/mak-it/omniauth-swedbank'
spec.homepage = 'https://github.com/mitigate-dev/omniauth-swedbank'
spec.license = 'MIT'

spec.files = `git ls-files`.split($/)
Expand All @@ -20,11 +20,12 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.2.2'

spec.add_runtime_dependency 'omniauth', '~> 1.0'
spec.add_runtime_dependency "i18n"
spec.add_runtime_dependency 'omniauth', '~> 2.1'
spec.add_runtime_dependency 'i18n'

spec.add_development_dependency 'rack', '~> 2.0'
spec.add_development_dependency 'rack-test'
spec.add_development_dependency 'rspec', '~> 2.7'
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
end
12 changes: 11 additions & 1 deletion spec/omniauth/strategies/swedbank_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'rack-protection'

describe OmniAuth::Strategies::Swedbank do

Expand All @@ -11,6 +12,8 @@
b.run lambda{|env| [404, {}, ['Not Found']]}
end.to_app }

let(:token){ Rack::Protection::AuthenticityToken.random_token }

let(:last_response_nonce) { last_response.body.match(/name="VK_NONCE" value="([^"]*)"/)[1] }
let(:last_response_mac) { last_response.body.match(/name="VK_MAC" value="([^"]*)"/)[1] }

Expand All @@ -23,7 +26,14 @@
'VK_RETURN' => 'http://example.org/auth/swedbank/callback'
}

before(:each){ get '/auth/swedbank' }
before(:each) do
post(
'/auth/swedbank',
{},
'rack.session' => {csrf: token},
'HTTP_X_CSRF_TOKEN' => token
)
end

it 'displays a single form' do
expect(last_response.status).to eq(200)
Expand Down

0 comments on commit 27700b6

Please sign in to comment.