omniauth-line-login 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 36e8441f59c7ffa46a93a4516716e930ce335a879812678609a3d3a1e380c1f2
4
+ data.tar.gz: bdbf3c1542f88253dc2a7073f4e4ad448392a81437359c2d2c69ddaa6f851c7f
5
+ SHA512:
6
+ metadata.gz: 4235a6357c0f8874e1c24af15c2a98cf500fec0bbc075098b358f1edae0e7d571f8672e3860950a296c2a78fc53b44233f8d018d27f62962065e95026a1daa5f
7
+ data.tar.gz: 9da5d436a8a8d70ea490dad680b95379230a432eec2bf0841ef610878d95639acdf92d2f8c49dfa69c09e5f0c12ced802f5370f46863193450c70082e08865a4
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 kazasiki
4
+ Copyright (c) 2026 buferago
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # OmniAuth LINE Login
2
+
3
+ OmniAuth strategy for [LINE Login](https://developers.line.biz/en/docs/line-login/overview/) with OpenID Connect email support.
4
+
5
+ This is a fork of [omniauth-line](https://github.com/kazasiki/omniauth-line) by kazasiki, enhanced with ID Token verification to extract `email` and `email_verified` claims via LINE's `/oauth2/v2.1/verify` API.
6
+
7
+ ## Installation
8
+
9
+ Add to your Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-line-login'
13
+ ```
14
+
15
+ Then `bundle install`.
16
+
17
+ ## Usage
18
+
19
+ ```ruby
20
+ # config/initializers/omniauth.rb or devise.rb
21
+ config.omniauth :line, ENV['LINE_CHANNEL_ID'], ENV['LINE_CHANNEL_SECRET'],
22
+ scope: 'profile openid email'
23
+ ```
24
+
25
+ **Important**: The `email` scope is required to receive an ID Token containing email claims. You must also apply for the "Email address" permission in your LINE Developers Console channel settings.
26
+
27
+ ## What's Different from omniauth-line
28
+
29
+ The original `omniauth-line` gem only calls LINE's `/v2/profile` API, which does not return email. This fork adds:
30
+
31
+ - **ID Token verification** via LINE's `/oauth2/v2.1/verify` API (server-side verification)
32
+ - **`info[:email]`** — extracted from the verified ID Token claims
33
+ - **`info[:email_verified]`** — the `email_verified` claim from the ID Token
34
+ - **`extra[:id_token_claims]`** — full ID Token claims for debugging and extension
35
+
36
+ ## Auth Hash
37
+
38
+ ```ruby
39
+ {
40
+ uid: 'U02fa1e93...',
41
+ info: {
42
+ name: 'Display Name',
43
+ image: 'https://profile.line-scdn.net/...',
44
+ description: 'Status message',
45
+ email: 'user@example.com', # NEW
46
+ email_verified: true # NEW
47
+ },
48
+ extra: {
49
+ raw_info: { ... }, # LINE /v2/profile response
50
+ id_token_claims: { ... } # NEW: verified ID Token claims
51
+ }
52
+ }
53
+ ```
54
+
55
+ ## Error Handling
56
+
57
+ If the ID Token is not present (e.g., `openid` scope not included) or the verify API returns an error, `email` and `email_verified` will be `nil` and the application can fall back to its own email collection flow. Errors are logged via `OmniAuth.logger`.
58
+
59
+ ## Nonce Verification
60
+
61
+ This gem does **not** perform nonce verification. If your application requires nonce validation, you can access the nonce from `extra[:id_token_claims]['nonce']` and verify it in your callback controller.
62
+
63
+ ## License
64
+
65
+ MIT License. See [LICENSE](LICENSE) for details.
66
+
67
+ Original work by [kazasiki](https://github.com/kazasiki/omniauth-line).
68
+
69
+ Repository: [buferago/omniauth-line](https://github.com/buferago/omniauth-line)
@@ -0,0 +1,90 @@
1
+ require 'omniauth-oauth2'
2
+ require 'json'
3
+ require 'net/http'
4
+ require 'uri'
5
+
6
+ module OmniAuth
7
+ module Strategies
8
+ class Line < OmniAuth::Strategies::OAuth2
9
+ option :name, 'line'
10
+ option :scope, 'profile openid'
11
+
12
+ option :client_options, {
13
+ site: 'https://access.line.me',
14
+ authorize_url: '/oauth2/v2.1/authorize',
15
+ token_url: '/oauth2/v2.1/token'
16
+ }
17
+
18
+ # LINE API のベース URL が認可とリソースで異なるため、
19
+ # callback 時に api.line.me に切り替える(本家踏襲)
20
+ def callback_phase
21
+ options[:client_options][:site] = 'https://api.line.me'
22
+ super
23
+ end
24
+
25
+ def callback_url
26
+ options[:callback_url] || (full_host + script_name + callback_path)
27
+ end
28
+
29
+ uid { raw_info['userId'] }
30
+
31
+ info do
32
+ {
33
+ name: raw_info['displayName'],
34
+ image: raw_info['pictureUrl'],
35
+ description: raw_info['statusMessage'],
36
+ email: id_token_claims['email'],
37
+ email_verified: id_token_claims['email_verified']
38
+ }
39
+ end
40
+
41
+ extra do
42
+ {
43
+ raw_info: raw_info,
44
+ id_token_claims: id_token_claims
45
+ }
46
+ end
47
+
48
+ def raw_info
49
+ @raw_info ||= JSON.parse(access_token.get('v2/profile').body)
50
+ rescue ::Errno::ETIMEDOUT
51
+ raise ::Timeout::Error
52
+ end
53
+
54
+ private
55
+
56
+ VERIFY_URL = URI('https://api.line.me/oauth2/v2.1/verify')
57
+
58
+ # LINE /oauth2/v2.1/verify API で ID Token をサーバー側検証し、クレームを取得
59
+ # access_token オブジェクトに依存せず、Net::HTTP で直接呼び出す(site 依存を排除)
60
+ # エラー時は空ハッシュを返しフォールバック(メール入力フローへ)
61
+ def id_token_claims
62
+ return @id_token_claims if defined?(@id_token_claims)
63
+
64
+ id_token = access_token.params&.[]('id_token')
65
+ if id_token.nil? || id_token.to_s.empty?
66
+ return @id_token_claims = {}
67
+ end
68
+
69
+ resp = Net::HTTP.post_form(VERIFY_URL, {
70
+ id_token: id_token,
71
+ client_id: options.client_id
72
+ })
73
+
74
+ unless resp.is_a?(Net::HTTPSuccess)
75
+ log(:warn, "LINE verify API returned #{resp.code}: #{resp.body}")
76
+ return @id_token_claims = {}
77
+ end
78
+
79
+ @id_token_claims = JSON.parse(resp.body)
80
+ rescue JSON::ParserError, Net::OpenTimeout, Net::ReadTimeout, SocketError, Errno::ECONNREFUSED => e
81
+ log(:warn, "LINE ID Token verification failed: #{e.class} - #{e.message}")
82
+ @id_token_claims = {}
83
+ end
84
+
85
+ def log(level, message)
86
+ OmniAuth.logger.send(level, "(line) #{message}") if OmniAuth.logger
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Line
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-line-login/version'
2
+ require 'omniauth/strategies/line'
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-line-login/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-line-login"
7
+ s.version = OmniAuth::Line::VERSION
8
+ s.authors = ["kazasiki", "buferago"]
9
+ s.email = ["kazasiki@gmail.com"]
10
+ s.homepage = "https://github.com/buferago/omniauth-line"
11
+ s.description = %q{OmniAuth strategy for LINE Login with OpenID Connect email support}
12
+ s.summary = %q{OmniAuth strategy for LINE Login - fork with ID token email extraction}
13
+ s.license = "MIT"
14
+
15
+ s.files = Dir['lib/**/*', 'LICENSE', 'README.md', '*.gemspec']
16
+ s.require_paths = ["lib"]
17
+
18
+ s.required_ruby_version = ">= 2.7"
19
+
20
+ s.add_dependency 'json', '>= 2.3.0'
21
+ s.add_dependency 'omniauth-oauth2', '~> 1.8'
22
+ s.add_development_dependency 'bundler', '~> 2.0'
23
+ s.add_development_dependency 'rspec', '~> 3.0'
24
+ s.add_development_dependency 'rack-test'
25
+ s.add_development_dependency 'webmock'
26
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-line-login
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - kazasiki
8
+ - buferago
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2026-03-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 2.3.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 2.3.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: omniauth-oauth2
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.8'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.8'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rack-test
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: webmock
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description: OmniAuth strategy for LINE Login with OpenID Connect email support
99
+ email:
100
+ - kazasiki@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - LICENSE
106
+ - README.md
107
+ - lib/omniauth-line-login.rb
108
+ - lib/omniauth-line-login/version.rb
109
+ - lib/omniauth/strategies/line.rb
110
+ - omniauth-line-login.gemspec
111
+ homepage: https://github.com/buferago/omniauth-line
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '2.7'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubygems_version: 3.3.27
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: OmniAuth strategy for LINE Login - fork with ID token email extraction
134
+ test_files: []