Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/coverage
/coverage/*
*.DS_Store
*.gem
95 changes: 95 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
PATH
remote: .
specs:
omniauth-line-messenger (0.3.1)
json (>= 2.3.0)
omniauth-oauth2 (~> 1.3)

GEM
remote: https://rubygems.org/
specs:
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
base64 (0.2.0)
bigdecimal (3.1.8)
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.5.1)
docile (1.4.1)
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
hashdiff (1.1.1)
hashie (5.0.0)
json (2.7.2)
jwt (2.9.0)
base64
multi_xml (0.6.0)
oauth2 (2.0.9)
faraday (>= 0.17.3, < 3.0)
jwt (>= 1.0, < 3.0)
multi_xml (~> 0.5)
rack (>= 1.2, < 4)
snaky_hash (~> 2.0)
version_gem (~> 1.1)
omniauth (2.1.2)
hashie (>= 3.4.6)
rack (>= 2.2.3)
rack-protection
omniauth-oauth2 (1.8.0)
oauth2 (>= 1.4, < 3)
omniauth (~> 2.0)
public_suffix (5.1.1)
rack (3.1.7)
rack-protection (3.0.6)
rack
rack-test (2.1.0)
rack (>= 1.3)
rake (13.2.1)
rexml (3.3.7)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
ruby2_keywords (0.0.5)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
version_gem (1.1.4)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
arm64-darwin-22

DEPENDENCIES
bundler (~> 2.0)
omniauth-line-messenger!
rack-test
rake
rspec (~> 3.2)
simplecov
webmock

BUNDLED WITH
2.4.22
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Supports the OpenID Connect Web Login. Read the Line developers docs for more de
First start by adding this gem to your Gemfile:

```ruby
gem 'omniauth-line'
gem 'omniauth-line-messenger'
```

Next, tell OmniAuth about this provider. For a Rails app, your `config/initializers/omniauth.rb` file should look like this:
Expand All @@ -32,6 +32,7 @@ An example auth hash available in `request.env['omniauth.auth']`:
:name => "yamada tarou",
:image => "http://dl.profile.line.naver.jp/xxxxx",
:description => "breakfast now.",
:email => "[email protected]"
},
:credentials => {
:token => "a1b2c3d4...", # The OAuth 2.0 access token
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/omniauth-line/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module OmniAuth
module Line
VERSION = "0.1.0"
VERSION = "0.3.2"
end
end
14 changes: 11 additions & 3 deletions lib/omniauth/strategies/line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module OmniAuth
module Strategies
class Line < OmniAuth::Strategies::OAuth2
option :name, 'line'
option :scope, 'profile openid'
option :scope, 'profile openid email'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem is making it default will make it harder when prototyping.
I wonder if it could be made an easy option...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what I was talking about ...


option :client_options, {
site: 'https://access.line.me',
Expand All @@ -23,14 +23,16 @@ def callback_url
# Fixes regression in omniauth-oauth2 v1.4.0 by https://github.com/intridea/omniauth-oauth2/commit/85fdbe117c2a4400d001a6368cc359d88f40abc7
options[:callback_url] || (full_host + script_name + callback_path)
end

uid { raw_info['userId'] }

info do
{
name: raw_info['displayName'],
image: raw_info['pictureUrl'],
description: raw_info['statusMessage']
description: raw_info['statusMessage'],
email: fetch_email
# email: JWT.decode(access_token.params['id_token'], options['client_secret']).first&.dig('email')
}
end

Expand All @@ -41,6 +43,12 @@ def raw_info
raise ::Timeout::Error
end

def fetch_email
data = JSON.load(access_token.post('oauth2/v2.1/verify', params: { id_token: access_token.params['id_token'], client_id: options['client_id'] }).body)
data['email']
rescue ::Errno::ETIMEDOUT
raise ::Timeout::Error
end
end
end
end
8 changes: 4 additions & 4 deletions omniauth-line.gemspec → omniauth-line-messenger.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
require "omniauth-line/version"

Gem::Specification.new do |s|
s.name = "omniauth-line"
s.name = "omniauth-line-messenger"
s.version = OmniAuth::Line::VERSION
s.authors = ["kazasiki"]
s.email = ["kazasiki@gmail.com"]
s.homepage = "https://github.com/kazasiki/omniauth-line"
s.authors = ["kazasiki", "marsz"]
s.email = ["marsz330@gmail.com"]
s.homepage = "https://github.com/marsz/omniauth-line-messenger"
s.description = %q{OmniAuth strategy for Line}
s.summary = s.description
s.license = "MIT"
Expand Down
2 changes: 2 additions & 0 deletions spec/omniauth/strategies/line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
describe 'uid' do
before do
allow(subject).to receive(:raw_info).and_return(raw_info_hash)
allow(subject).to receive(:fetch_email).and_return('[email protected]')
end

it 'should returns the uid' do
Expand All @@ -43,6 +44,7 @@
describe 'info' do
before do
allow(subject).to receive(:raw_info).and_return(raw_info_hash)
allow(subject).to receive(:fetch_email).and_return('[email protected]')
end

it 'should returns the name' do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
require 'rack/test'
require 'webmock/rspec'
require 'omniauth'
require 'omniauth-line'
require 'omniauth-line-messenger'

RSpec.configure do |config|
config.include WebMock::API
Expand Down