mobile_id 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd821489ca866a30d97debb4b24438558dc578a94b20e34c1620481c7a0fc54d
4
- data.tar.gz: 8c1f3d4f40d90698c05f8d7112e7507966e480baa6c8c3a37cb8035d2dddf4d1
3
+ metadata.gz: 7d38624f18a2ecc7fc1118e8f4cbe3d02276d13a1e04a2cd224c65b63eecab66
4
+ data.tar.gz: 3fe078951586eca758a792918c705306f2a2058f2f63385cfe4eb18cd1455a16
5
5
  SHA512:
6
- metadata.gz: c90fde223c4830be512c78682421fc06848346a9ec81193e8afe8b13379878301c9c1479a04dddc872d2f19a34d72dee986233031c51c9a607601259c6b69cf0
7
- data.tar.gz: 6118400c09a3a34bb687420338be9757f28c7f7273d39a56b352348f0dbcea3908768752998101a28ed7c4d006e39e7020e57b99f7be8fc4859a6dc3cb85711a
6
+ metadata.gz: 68b5151f552cdc6ef5730ef3a9ed21cffed2cf18a839deb32f91039cbbabf73b47bd0aad4f2046f57b9452c395b41f23c525d35aa6935adca7f80139a32ff805
7
+ data.tar.gz: 8eff21fe89c9a3f6c3328e326cae799ad4c727d3545255d41c643a53702058b544ba811e2083635ba303077e57bbc7c493f1fdf1e94ba9b6dcfdf39b83fffc3c
@@ -0,0 +1,8 @@
1
+ Release 0.0.3
2
+ * Gemspec update
3
+
4
+ Release 0.0.2
5
+ * Readme update
6
+
7
+ Release 0.0.1
8
+ * Init
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2019-2020, Priit Tark, priit@gitlab.eu
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,127 @@
1
+ # MobileId::Ruby::Gem
2
+
3
+ Estonia Mobile ID authentication, more info at https://www.id.ee/en/
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mobile_id'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install mobile_id
20
+
21
+ ## Test usage
22
+
23
+ Execute irb:
24
+
25
+ $ bundle exec irb
26
+ irb(main):001:0> require 'mobile_id'
27
+ => true
28
+ irb(main):002:0> @mid = MobileId.new(live: false)
29
+ => #<MobileId:0x000055ac4cb25630 @url="https://tsp.demo.sk.ee/mid-api", @uuid="00000000-0000-0000-0000-000000000000", @name="DEMO", @hash="two+e7UMoFCAXHo8q9AnWqSC58Hhil74RowY8Gg9xQY=">
30
+ irb(main):003:0> auth = @mid.authenticate!(phone: '00000766', personal_code: '60001019906')
31
+ => {"session_id"=>"34e7eff0-691b-4fad-9798-8db680587b18", "phone"=>"00000766", "phone_calling_code"=>"+372"}
32
+ irb(main):004:0> verify = @mid.verify!(auth)
33
+ => {"personal_code"=>"60001019906", "first_name"=>"MARY ÄNN", "last_name"=>"O’CONNEŽ-ŠUSLIK TESTNUMBER", "phone"=>"00000766", "phone_calling_code"=>"+372", "auth_provider"=>"mobileid"}
34
+
35
+ You get verified attributes: personal_code, first_name, last_name, phone, phone_calling_code, auth_provider
36
+
37
+
38
+ ## Live usage
39
+
40
+ For live usage, add your relyingPartyUUID (RPUUID) and relyingPartyName what you get from https://www.sk.ee
41
+
42
+ ```ruby
43
+ @mid = MobileId.new(live: true, uuid: "39e7eff0-241b-4fad-2798-9db680587b20", name: 'My service name')
44
+ ```
45
+
46
+ Rails with Devise example controller:
47
+
48
+ ```ruby
49
+ class MobileSessionsController < ApplicationController
50
+ include Devise::Controllers::Helpers
51
+ skip_authorization_check only: [:new, :show, :create, :update]
52
+ before_action :init_mobile_id, only: [:create, :update]
53
+
54
+ def new
55
+ @user = User.new
56
+ end
57
+
58
+ # makes Mobile ID authentication
59
+ def create
60
+ session[:auth] = @mid.authenticate!(phone: params[:phone], personal_code: params[:personal_code])
61
+ render :show, locals: { verification_code: @mid.verification_code }
62
+ rescue MobileId::Error => e
63
+ render :error, locals: { message: e }
64
+ end
65
+
66
+ # verifices Mobile ID user
67
+ def update
68
+ session[:auth] = @mid.verify!(session[:auth])
69
+ find_or_create_user_and_redirect(personal_code: @mid.personal_code)
70
+ rescue MobileId::Error => e
71
+ render :error, locals: { message: e }
72
+ end
73
+
74
+ private
75
+
76
+ def init_mobile_id
77
+ @mid = MobileId.new(live: true, uuid: ENV['sk_mid_uuid'], name: ENV['sk_mid_name'])
78
+ end
79
+
80
+ # It's pure your system business logic what to do here with validated user attributes, example code:
81
+ def find_or_create_user_and_redirect(personal_code:)
82
+ @user = User.find_by(personal_code: personal_code)
83
+
84
+ # bind currently present email only account with mobile-id
85
+ if @user.nil? && current_user&.confirmed_email_only_account?
86
+ @user = current_user
87
+ @user.personal_code = personal_code
88
+ @user.save!
89
+ end
90
+
91
+ return redirect_to new_omniuser_url, notice: t(:finish_setup) if @user.nil? || @user.new_record?
92
+ return redirect_to root_url, alert: t(:unlock_info) if @user.access_locked?
93
+
94
+ if @user.valid? && @user.confirmed_at
95
+ # overwrite name changes
96
+ @user.first_name = session[:auth]['first_name'] if session[:auth]['first_name'].present?
97
+ @user.last_name = session[:auth]['last_name'] if session[:auth]['last_name'].present?
98
+ @user.save! if @user.changed?
99
+
100
+ sign_in_and_redirect(@user, notice: t('devise.sessions.signed_in'))
101
+ else
102
+ redirect_to edit_omniuser_url(@user), notice: t('devise.failure.unconfirmed')
103
+ end
104
+ end
105
+ end
106
+ ```
107
+
108
+ ## Development
109
+
110
+ After checking out the repo, run `bundle` to install dependencies. For testing code, run `rspec`
111
+
112
+ ## Contributing
113
+
114
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gitlabeu/mobile_id
115
+
116
+ ## Roadmap
117
+
118
+ * Document sign
119
+ * Rails generators
120
+
121
+ ## License
122
+
123
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
124
+
125
+ ## Sponsors
126
+
127
+ Gem development and testing is sponsored by [GiTLAB](https://gitlab.eu).
@@ -0,0 +1,10 @@
1
+ en:
2
+ mobile_id:
3
+ some_error: There was some error
4
+ timeout: "Mobile-ID session got timeout"
5
+ user_is_not_mobile_id_client: User is not Mobile-ID client.
6
+ user_cancelled: User cancelled the Mobile ID operation
7
+ signature_hash_mismatch: "Mobile-ID has signiture issue. User needs to contact his/her mobile operator."
8
+ phone_absent: Mobile-ID SIM not available
9
+ delivery_error: Mobile-ID SMS sending error.
10
+ sim_error: Invalid response from Mobile-ID SIM card
@@ -0,0 +1,10 @@
1
+ et:
2
+ mobile_id:
3
+ some_error: Tekkis viga
4
+ timeout: "Mobiil-ID sisselogimine aegus"
5
+ user_is_not_mobile_id_client: Kasutaja ei ole Mobiil-ID klient
6
+ user_cancelled: Kasutaja katkestas Mobiil-ID sisselogimise.
7
+ signature_hash_mismatch: "Mobiil-ID digiallkiri on vigane. Palun pöörduge oma mobiilioperaatori poole."
8
+ phone_absent: Kasutaja telefon ei asu levipiirkonnas või on välja lülitatud.
9
+ delivery_error: Mobiil-ID SMS saatmisel tekkis viga.
10
+ sim_error: Mobiil-ID telefoni SIM viga.
@@ -0,0 +1,10 @@
1
+ ru:
2
+ mobile_id:
3
+ some_error: Была некоторая ошибка
4
+ timeout: "Mobile-ID session got timeout"
5
+ user_is_not_mobile_id_client: User is not Mobile-ID client.
6
+ user_cancelled: User cancelled the Mobile ID operation
7
+ signature_hash_mismatch: "Mobile-ID has signiture issue. User needs to contact his/her mobile operator."
8
+ phone_absent: Mobile-ID SIM not available
9
+ delivery_error: Mobile-ID SMS sending error.
10
+ sim_error: Invalid response from Mobile-ID SIM card
@@ -0,0 +1,13 @@
1
+ require 'rails'
2
+
3
+ module MobileId
4
+ class Railtie < ::Rails::Railtie #:nodoc:
5
+ initializer 'mobile_id' do |app|
6
+ DeviseI18n::Railtie.instance_eval do
7
+ app.config.i18n.available_locales.each do |loc|
8
+ I18n.load_path << Dir[File.expand_path("lib/mobile_id/locales") + "/#{loc}.yml"]
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobile_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Priit Tark
@@ -100,7 +100,14 @@ executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
+ - CHANGELOG.md
104
+ - MIT-LICENSE
105
+ - README.md
103
106
  - lib/mobile_id.rb
107
+ - lib/mobile_id/locales/en.yml
108
+ - lib/mobile_id/locales/et.yml
109
+ - lib/mobile_id/locales/ru.yml
110
+ - lib/mobile_id/railtie.rb
104
111
  homepage: https://github.com/gitlabeu/mobile_id
105
112
  licenses:
106
113
  - MIT