omniauth-line-v2_1 1.0.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4daab37331c6e52d1d1ee084436b0e657c911d1aabaaeab22082c67d54fb02a7
4
- data.tar.gz: 0e14607b895b14419ff4c805cf0f4669b7f0e1778a4b1c6b074a01de69bc1d39
3
+ metadata.gz: 48b7eabf165102c77a028447af025a49a0d96fef443212573ca39e1f5607cfe3
4
+ data.tar.gz: 3e660975cc14731e0063e5efb9b326bead51bb60ffc92fd66738f0b7cf02ee5e
5
5
  SHA512:
6
- metadata.gz: 0dbb8a42057f34f02182d549ee477ea3125e53496a4849bb8549d335d40b3c38509c77addeab62fc382f564d8bd2667c967791455af52749e9160cd14379e551
7
- data.tar.gz: a9d34cbeb50f3dc972fefadd63a5e3b683f7355c300c382663bd47dca4c7891f775a5f59f88718f6499c231907e6152fde2c9761450bd9fdb7803ae327432803
6
+ metadata.gz: 15acff7703daf08e09128e2116f631376f7b50f067cbc1a56df6d882a7e98140dafdde1023338558917bb21bc1f3f9a3ab447ea91c426ebec79d94c256e45cc9
7
+ data.tar.gz: c20139b4ac5542d34f70656e86917e0b4e62947033f4eab5fe65d1eb38e9e84e448c9f0f86258e54246041b17d94313b0d2612e75f2c0e5acb02241edf42511d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0] - 2025-11-03
4
+
5
+ - Refactor: Remove redundant user info endpoint call
6
+ - Test: Update test
7
+ - Other: Update README.md
8
+
9
+ ## [1.1.0] - 2025-08-02
10
+
11
+ - Refactor: Refactor `OmniAuth::Strategies::LineV21#authorize_params`
12
+ - Test: Update test
13
+
3
14
  ## [1.0.0] - 2025-08-01
4
15
 
5
16
  - New: Generate nonce parameter automatically for security
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![License](https://img.shields.io/github/license/cadenza-tech/omniauth-line-v2_1?label=License&labelColor=343B42&color=blue)](https://github.com/cadenza-tech/omniauth-line-v2_1/blob/main/LICENSE.txt) [![Tag](https://img.shields.io/github/tag/cadenza-tech/omniauth-line-v2_1?label=Tag&logo=github&labelColor=343B42&color=2EBC4F)](https://github.com/cadenza-tech/omniauth-line-v2_1/blob/main/CHANGELOG.md) [![Release](https://github.com/cadenza-tech/omniauth-line-v2_1/actions/workflows/release.yml/badge.svg)](https://github.com/cadenza-tech/omniauth-line-v2_1/actions?query=workflow%3Arelease) [![Test](https://github.com/cadenza-tech/omniauth-line-v2_1/actions/workflows/test.yml/badge.svg)](https://github.com/cadenza-tech/omniauth-line-v2_1/actions?query=workflow%3Atest) [![Lint](https://github.com/cadenza-tech/omniauth-line-v2_1/actions/workflows/lint.yml/badge.svg)](https://github.com/cadenza-tech/omniauth-line-v2_1/actions?query=workflow%3Alint)
4
4
 
5
- LINE Login v2.1 strategy for OmniAuth.
5
+ LINE strategy for OmniAuth.
6
6
 
7
7
  - [Installation](#installation)
8
8
  - [Usage](#usage)
@@ -105,11 +105,6 @@ After successful authentication, the auth hash will be available in `request.env
105
105
  refresh_token: 'Aa1FdeggRhTnPNNpxr8p'
106
106
  },
107
107
  extra: {
108
- raw_info: {
109
- sub: 'U4af4980629...',
110
- name: 'Taro Line',
111
- picture: 'https://profile.line-scdn.net/...'
112
- },
113
108
  id_token: 'eyJhbGciOiJIUzI1NiJ9...',
114
109
  id_info: {
115
110
  iss: 'https://access.line.me',
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module LineV21
5
- VERSION = '1.0.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
@@ -1,40 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'omniauth-oauth2'
4
+ require 'uri'
4
5
 
5
6
  module OmniAuth
6
7
  module Strategies
7
8
  class LineV21 < OmniAuth::Strategies::OAuth2
8
9
  DEFAULT_SCOPE = 'profile openid email'
9
- USER_INFO_URL = 'https://api.line.me/oauth2/v2.1/userinfo'
10
10
  ID_TOKEN_VERIFY_URL = 'https://api.line.me/oauth2/v2.1/verify'
11
11
 
12
12
  option :name, 'line_v2_1'
13
-
14
13
  option :client_options, {
15
14
  site: 'https://access.line.me',
16
15
  authorize_url: '/oauth2/v2.1/authorize',
17
16
  token_url: 'https://api.line.me/oauth2/v2.1/token'
18
17
  }
19
-
20
18
  option :authorize_options, [:scope, :state, :nonce, :prompt, :bot_prompt]
21
-
22
19
  option :scope, DEFAULT_SCOPE
23
20
 
24
- uid { raw_info['sub'] }
21
+ uid { id_token_info[:decoded]['sub'] }
25
22
 
26
23
  info do
27
24
  prune!({
28
- name: raw_info['name'],
29
- nickname: raw_info['sub'],
30
- image: raw_info['picture'],
25
+ name: id_token_info[:decoded]['name'],
26
+ nickname: id_token_info[:decoded]['sub'],
27
+ image: id_token_info[:decoded]['picture'],
31
28
  email: id_token_info[:decoded]['email']
32
29
  })
33
30
  end
34
31
 
35
32
  extra do
36
33
  hash = {}
37
- hash[:raw_info] = raw_info unless skip_info?
38
34
  hash[:id_token] = id_token_info[:raw] if id_token_info[:raw]
39
35
  hash[:id_info] = id_token_info[:decoded] if id_token_info[:decoded]
40
36
  prune!(hash)
@@ -48,24 +44,20 @@ module OmniAuth
48
44
  hash
49
45
  end
50
46
 
51
- def raw_info
52
- @raw_info ||= access_token.get(USER_INFO_URL, headers: { 'Authorization' => "Bearer #{access_token.token}" }).parsed
53
- end
54
-
55
47
  def callback_url
56
48
  options[:redirect_uri] || (full_host + callback_path)
57
49
  end
58
50
 
59
- def authorize_params
51
+ def authorize_params # rubocop:disable Metrics/AbcSize
60
52
  super.tap do |params|
61
- %w[scope state nonce prompt bot_prompt].each do |v|
62
- params[v.to_sym] = request.params[v] if request.params[v]
53
+ options[:authorize_options].each do |key|
54
+ params[key] = request.params[key.to_s] unless empty?(request.params[key.to_s])
63
55
  end
64
56
  params[:scope] ||= DEFAULT_SCOPE
65
57
  params[:nonce] ||= SecureRandom.hex(24)
66
58
  params[:response_type] = 'code'
67
- session['omniauth.state'] = params[:state] if params[:state]
68
- session['omniauth.nonce'] = params[:nonce] if params[:nonce]
59
+ session['omniauth.state'] = params[:state] unless empty?(params[:state])
60
+ session['omniauth.nonce'] = params[:nonce] unless empty?(params[:nonce])
69
61
  end
70
62
  end
71
63
 
@@ -74,10 +66,14 @@ module OmniAuth
74
66
  def prune!(hash)
75
67
  hash.delete_if do |_, value|
76
68
  prune!(value) if value.is_a?(Hash)
77
- value.nil? || (value.respond_to?(:empty?) && value.empty?)
69
+ empty?(value)
78
70
  end
79
71
  end
80
72
 
73
+ def empty?(value)
74
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
75
+ end
76
+
81
77
  def id_token_info
82
78
  return @id_token_info if defined?(@id_token_info)
83
79
 
@@ -85,11 +81,11 @@ module OmniAuth
85
81
  return @id_token_info unless access_token.params['id_token']
86
82
 
87
83
  @id_token_info[:raw] = access_token.params['id_token']
88
- @id_token_info[:decoded] = verify_id_token(access_token.params['id_token'])
84
+ @id_token_info[:decoded] = verify_and_decode_id_token(access_token.params['id_token'])
89
85
  @id_token_info
90
86
  end
91
87
 
92
- def verify_id_token(id_token)
88
+ def verify_and_decode_id_token(id_token)
93
89
  params = {
94
90
  id_token: id_token,
95
91
  client_id: options.client_id
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-line-v2_1
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro
@@ -37,7 +37,7 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1.8'
40
- description: LINE Login v2.1 strategy for OmniAuth
40
+ description: LINE strategy for OmniAuth
41
41
  email:
42
42
  - watanabe@cadenza-tech.com
43
43
  executables: []
@@ -52,15 +52,15 @@ files:
52
52
  - lib/omniauth-line-v2_1.rb
53
53
  - lib/omniauth/line_v2_1/version.rb
54
54
  - lib/omniauth/strategies/line_v2_1.rb
55
- homepage: https://github.com/cadenza-tech/omniauth-line-v2_1/tree/v1.0.0
55
+ homepage: https://github.com/cadenza-tech/omniauth-line-v2_1/tree/v1.2.0
56
56
  licenses:
57
57
  - MIT
58
58
  metadata:
59
- homepage_uri: https://github.com/cadenza-tech/omniauth-line-v2_1/tree/v1.0.0
60
- source_code_uri: https://github.com/cadenza-tech/omniauth-line-v2_1/tree/v1.0.0
61
- changelog_uri: https://github.com/cadenza-tech/omniauth-line-v2_1/blob/v1.0.0/CHANGELOG.md
59
+ homepage_uri: https://github.com/cadenza-tech/omniauth-line-v2_1/tree/v1.2.0
60
+ source_code_uri: https://github.com/cadenza-tech/omniauth-line-v2_1/tree/v1.2.0
61
+ changelog_uri: https://github.com/cadenza-tech/omniauth-line-v2_1/blob/v1.2.0/CHANGELOG.md
62
62
  bug_tracker_uri: https://github.com/cadenza-tech/omniauth-line-v2_1/issues
63
- documentation_uri: https://rubydoc.info/gems/omniauth-line-v2_1/1.0.0
63
+ documentation_uri: https://rubydoc.info/gems/omniauth-line-v2_1/1.2.0
64
64
  funding_uri: https://patreon.com/CadenzaTech
65
65
  rubygems_mfa_required: 'true'
66
66
  rdoc_options: []
@@ -79,5 +79,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  requirements: []
80
80
  rubygems_version: 3.6.9
81
81
  specification_version: 4
82
- summary: LINE Login v2.1 strategy for OmniAuth
82
+ summary: LINE strategy for OmniAuth
83
83
  test_files: []