TagoLine 0.1.4.11 → 0.1.4.13

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: 2b44b1562e4fdab2342d5484cadbd85d74ff301ec0b7a4c46b563a095cd0343b
4
- data.tar.gz: 89f744db564ee2dfec4e03da8770dda1fcbced8932f78c6096179993024c36ca
3
+ metadata.gz: 0ad783064093fe816e6b946d865131820e8fffede606daca53905eebe89ab627
4
+ data.tar.gz: 75bc783719c3e500b28d92d703938ac264a20d1ddb636f43482425287117f762
5
5
  SHA512:
6
- metadata.gz: a5c399fd753951ba96cd805fe55a0e5a708e24a3c98fa738f5888d197bceb0e050ba624e3a152f132bc290e71838467b5de91a993449ccc5c5cfd3022d478a43
7
- data.tar.gz: 55f717d9a261577c44b9708a5a1b69afc7e133850d840e3a8a4168adb5377d8f8b60aee77dfe356fea81c7fb22fea21cc12f9db74825b0b2ae1e5b6065c5619c
6
+ metadata.gz: d373227e52a98509ef0a160e6655ac62a886fd2b1f5c4acc7f9f5b2fc3013a0454295ee8dbcb32126009ad5b6358d5135cb79144981d6ce2bacd7e2d435b8c5b
7
+ data.tar.gz: 929ebc39b774cdbaf7effa44da1f180a1da563c0ea79fa354b192954c6536847ad09b5dc43924c6050b804616416c826b31e4e25c892fbb447b03f3032269673
data/README.md CHANGED
@@ -10,5 +10,14 @@ LINE_CHANNEL_SECRET
10
10
  ## ログインボタン
11
11
  ビューの中でこう書きます。
12
12
  ```
13
- <%= TagoLine::LoginButton.show %>
14
- ```
13
+ <%= TagoLine::LoginButton.show(controller) %>
14
+ ```
15
+ セッションを使うため、引数にcontrollerが必要です
16
+
17
+ ## CSRFのチェック
18
+ ```
19
+ TagoLine::LoginAction.stateIsRight(self)
20
+ ```
21
+ コントローラー内でこのように書く。
22
+ URLのパラメーターにあるstateとsession[:line_state]を比較した結果を返す
23
+
@@ -0,0 +1,18 @@
1
+ require 'rails/all'
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ module TagoLine
6
+ class LoginAction
7
+ def self.stateIsRight(controller)
8
+ controller.session[:line_state] == controller.params[:state]
9
+ end
10
+
11
+ def self.getAccessToken(controller)
12
+ uri = URI('https://api.line.me/oauth2/v2.1/token')
13
+ res = Net::HTTP.post_form(uri, 'grant_type' => 'authorization_code', 'redirect_uri' => ENV['LINE_CALLBACK_URL'], 'client_id' => ENV['LINE_CHANNEL_ID'], 'client_secret' => ENV['LINE_CHANNEL_SECRET'], 'code' => controller.params[:code])
14
+ JSON.parse(res.body)
15
+ end
16
+
17
+ end
18
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TagoLine
4
- VERSION = "0.1.4.11"
4
+ VERSION = "0.1.4.13"
5
5
  CALLBACK_URL = ENV["LINE_CALLBACK_URL"]
6
6
  CHANNEL_ID = ENV["LINE_CHANNEL_ID"]
7
7
  CHANNEL_SECRET = ENV["LINE_CHANNEL_SECRET"]
data/lib/TagoLine.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "TagoLine/version"
4
4
  require_relative "TagoLine/LoginButton"
5
+ require_relative "TagoLine/LoginAction"
5
6
 
6
7
  module TagoLine
7
8
  class Error < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TagoLine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.11
4
+ version: 0.1.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - manatago
@@ -25,6 +25,7 @@ files:
25
25
  - README.md
26
26
  - Rakefile
27
27
  - lib/TagoLine.rb
28
+ - lib/TagoLine/LoginAction.rb
28
29
  - lib/TagoLine/LoginButton.rb
29
30
  - lib/TagoLine/version.rb
30
31
  - memo.txt