Skip to content
This repository was archived by the owner on Aug 10, 2021. It is now read-only.

Commit ffbfdca

Browse files
author
Vasile Zaremba
committed
Add initial strategy code
1 parent 4758ec7 commit ffbfdca

File tree

13 files changed

+168
-5
lines changed

13 files changed

+168
-5
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ build-iPhoneSimulator/
4242

4343
# for a library or gem, you might want to ignore these files since the code is
4444
# intended to run in multiple environments; otherwise, check them in:
45-
# Gemfile.lock
46-
# .ruby-version
47-
# .ruby-gemset
45+
Gemfile.lock
46+
.ruby-version
47+
.ruby-gemset
4848

4949
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
5050
.rvmrc

.rspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--format documentation
2+
--color

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Vasile Zaremba
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,41 @@
1-
# yoti-plugin-omnitauth
2-
Ruby OmniAuth
1+
# Omniauth::Yoti
2+
3+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/yoti`. To experiment with that code, run `bin/console` for an interactive prompt.
4+
5+
TODO: Delete this and the text above, and describe your gem
6+
7+
## Installation
8+
9+
Add this line to your application's Gemfile:
10+
11+
```ruby
12+
gem 'omniauth-yoti'
13+
```
14+
15+
And then execute:
16+
17+
$ bundle
18+
19+
Or install it yourself as:
20+
21+
$ gem install omniauth-yoti
22+
23+
## Usage
24+
25+
TODO: Write usage instructions here
26+
27+
## Development
28+
29+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30+
31+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32+
33+
## Contributing
34+
35+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-yoti.
36+
37+
38+
## License
39+
40+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41+

Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require 'bundler/gem_tasks'
2+
require 'rspec/core/rake_task'
3+
4+
RSpec::Core::RakeTask.new(:spec)
5+
6+
task default: :spec

lib/omniauth-yoti.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require 'omniauth/yoti'

lib/omniauth/strategies/yoti.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
require 'omniauth'
2+
require 'yoti'
3+
require 'pry'
4+
5+
module OmniAuth
6+
module Strategies
7+
class Yoti
8+
include OmniAuth::Strategy
9+
10+
option :config, [:application_id, :client_sdk_id, :key_file_path]
11+
12+
def request_phase
13+
redirect "https://www.yoti.com/connect/#{options.config.first.application_id}"
14+
end
15+
16+
uid { @yoti_activity_details.user_id }
17+
info { { name: @yoti_activity_details.user_id } }
18+
19+
def extra
20+
@raw_info ||= begin
21+
user_profile = @yoti_activity_details.user_profile
22+
{
23+
photo: user_profile['selfie'],
24+
given_names: user_profile['given_names'],
25+
family_name: user_profile['family_name'],
26+
mobile_number: user_profile['phone_number'],
27+
date_of_birth: user_profile['date_of_birth'],
28+
address: user_profile['post_code'],
29+
gender: user_profile['gender'],
30+
nationality: user_profile['nationality']
31+
}
32+
end
33+
end
34+
35+
def callback_phase
36+
::Yoti.configure do |config|
37+
config.client_sdk_id = options.config.first.client_sdk_id
38+
config.key_file_path = options.config.first.key_file_path
39+
end
40+
41+
token = Rack::Utils.parse_nested_query(request.query_string)['token']
42+
@yoti_activity_details = ::Yoti::Client.get_activity_details(token)
43+
44+
super
45+
end
46+
end
47+
end
48+
end

lib/omniauth/yoti.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'omniauth/yoti/version'
2+
require 'omniauth/strategies/yoti'

lib/omniauth/yoti/version.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Omniauth
2+
module Yoti
3+
VERSION = '0.1.0'
4+
end
5+
end

0 commit comments

Comments
 (0)