omniauth-lastfm 1.0.3 → 1.0.5
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 +4 -4
- data/README.md +2 -2
- data/lib/omniauth/lastfm/version.rb +1 -1
- data/lib/omniauth/strategies/lastfm.rb +37 -37
- data/lib/omniauth-lastfm/version.rb +1 -1
- data/lib/omniauth-lastfm.rb +2 -2
- data/omniauth-lastfm.gemspec +20 -20
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a67ccc625319b274e05dcf6d72408609250311e4f7b49e69483908e9e4aba0b5
|
|
4
|
+
data.tar.gz: a1adf2888f18732b1beb8bfc1a1560355edeed485241c3734cc8d8efbff49c9f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74816a83bfad71a6bddd32a3d63e404d1657586d6dce4926d9ae5a1d4a120609795ce5a27b643d785408c379974f019933510885a98ecbeed7a8d3ba7d02f357
|
|
7
|
+
data.tar.gz: 16cb5487a86289dc826bef56ac687c869b442f27d0d9f94d0d633f61669d485efc308bbb47239ef0fa86e2c7b99a65662e10b6256ec50cbc30033140c19ac3de
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# OmniAuth Last.fm
|
|
1
|
+
# OmniAuth Last.fm Strategy
|
|
2
2
|
|
|
3
3
|
[](https://github.com/icoretech/omniauth-lastfm/actions/workflows/test.yml)
|
|
4
|
-
[](https://badge.fury.io/rb/omniauth-lastfm)
|
|
5
5
|
|
|
6
6
|
`omniauth-lastfm` is an OmniAuth strategy for authenticating with Last.fm.
|
|
7
7
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
3
|
+
require "digest/md5"
|
|
4
|
+
require "json"
|
|
5
|
+
require "net/http"
|
|
6
|
+
require "omniauth"
|
|
7
|
+
require "uri"
|
|
8
8
|
|
|
9
9
|
module OmniAuth
|
|
10
10
|
module Strategies
|
|
@@ -14,40 +14,40 @@ module OmniAuth
|
|
|
14
14
|
|
|
15
15
|
args %i[api_key secret_key]
|
|
16
16
|
|
|
17
|
-
option :name,
|
|
17
|
+
option :name, "lastfm"
|
|
18
18
|
option :api_key, nil
|
|
19
19
|
option :secret_key, nil
|
|
20
20
|
option :api_timeout, 10
|
|
21
21
|
option :client_options,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
site: "https://www.last.fm",
|
|
23
|
+
authorize_path: "/api/auth",
|
|
24
|
+
api_url: "https://ws.audioscrobbler.com/2.0/",
|
|
25
|
+
user_agent: "icoretech-omniauth-lastfm gem"
|
|
26
26
|
|
|
27
|
-
uid { session_data[
|
|
27
|
+
uid { session_data["name"] }
|
|
28
28
|
|
|
29
29
|
info do
|
|
30
30
|
{
|
|
31
|
-
nickname: user_data[
|
|
32
|
-
name: user_data[
|
|
33
|
-
url: user_data[
|
|
34
|
-
image: image_url(user_data[
|
|
35
|
-
country: user_data[
|
|
36
|
-
age: user_data[
|
|
37
|
-
gender: user_data[
|
|
31
|
+
nickname: user_data["name"],
|
|
32
|
+
name: user_data["realname"],
|
|
33
|
+
url: user_data["url"],
|
|
34
|
+
image: image_url(user_data["image"]),
|
|
35
|
+
country: user_data["country"],
|
|
36
|
+
age: user_data["age"],
|
|
37
|
+
gender: user_data["gender"]
|
|
38
38
|
}.compact
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
extra do
|
|
42
42
|
{
|
|
43
|
-
|
|
43
|
+
"raw_info" => user_data
|
|
44
44
|
}
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
credentials do
|
|
48
48
|
{
|
|
49
|
-
token: session_data[
|
|
50
|
-
name: session_data[
|
|
49
|
+
token: session_data["key"],
|
|
50
|
+
name: session_data["name"]
|
|
51
51
|
}.compact
|
|
52
52
|
end
|
|
53
53
|
|
|
@@ -64,19 +64,19 @@ module OmniAuth
|
|
|
64
64
|
def callback_phase
|
|
65
65
|
load_profile!
|
|
66
66
|
super
|
|
67
|
-
rescue
|
|
67
|
+
rescue => e
|
|
68
68
|
fail!(:invalid_credentials, e)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
protected
|
|
72
72
|
|
|
73
73
|
def load_profile!
|
|
74
|
-
token = request.params[
|
|
75
|
-
raise ArgumentError,
|
|
74
|
+
token = request.params["token"].to_s
|
|
75
|
+
raise ArgumentError, "Missing token parameter in callback request" if token.empty?
|
|
76
76
|
|
|
77
77
|
session_payload = fetch_json(session_params(token))
|
|
78
|
-
user_name = session_payload.dig(
|
|
79
|
-
raise ArgumentError,
|
|
78
|
+
user_name = session_payload.dig("session", "name").to_s
|
|
79
|
+
raise ArgumentError, "Missing session name in Last.fm session response" if user_name.empty?
|
|
80
80
|
|
|
81
81
|
@json = session_payload
|
|
82
82
|
@json.merge!(fetch_json(user_info_params(user_name)))
|
|
@@ -87,13 +87,13 @@ module OmniAuth
|
|
|
87
87
|
uri.query = URI.encode_www_form(params)
|
|
88
88
|
|
|
89
89
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
90
|
-
http.use_ssl = uri.scheme ==
|
|
90
|
+
http.use_ssl = uri.scheme == "https"
|
|
91
91
|
http.open_timeout = options.api_timeout
|
|
92
92
|
http.read_timeout = options.api_timeout
|
|
93
93
|
|
|
94
94
|
request = Net::HTTP::Get.new(uri.request_uri)
|
|
95
|
-
request[
|
|
96
|
-
request[
|
|
95
|
+
request["Accept"] = "application/json"
|
|
96
|
+
request["User-Agent"] = options.client_options.user_agent
|
|
97
97
|
|
|
98
98
|
response = http.request(request)
|
|
99
99
|
unless response.is_a?(Net::HTTPSuccess)
|
|
@@ -106,23 +106,23 @@ module OmniAuth
|
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
def session_data
|
|
109
|
-
@json&.fetch(
|
|
109
|
+
@json&.fetch("session", {}) || {}
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
def user_data
|
|
113
|
-
@json&.fetch(
|
|
113
|
+
@json&.fetch("user", {}) || {}
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
def image_url(value)
|
|
117
117
|
case value
|
|
118
118
|
when Array
|
|
119
119
|
value.reverse_each do |entry|
|
|
120
|
-
image = entry.fetch(
|
|
120
|
+
image = entry.fetch("#text", "").to_s
|
|
121
121
|
return image unless image.empty?
|
|
122
122
|
end
|
|
123
123
|
nil
|
|
124
124
|
when Hash
|
|
125
|
-
image = value.fetch(
|
|
125
|
+
image = value.fetch("#text", "").to_s
|
|
126
126
|
image.empty? ? nil : image
|
|
127
127
|
else
|
|
128
128
|
image = value.to_s
|
|
@@ -142,8 +142,8 @@ module OmniAuth
|
|
|
142
142
|
api_key: options.api_key,
|
|
143
143
|
token: token,
|
|
144
144
|
api_sig: signature(token),
|
|
145
|
-
method:
|
|
146
|
-
format:
|
|
145
|
+
method: "auth.getSession",
|
|
146
|
+
format: "json"
|
|
147
147
|
}
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -151,8 +151,8 @@ module OmniAuth
|
|
|
151
151
|
{
|
|
152
152
|
api_key: options.api_key,
|
|
153
153
|
user: user_name,
|
|
154
|
-
method:
|
|
155
|
-
format:
|
|
154
|
+
method: "user.getInfo",
|
|
155
|
+
format: "json"
|
|
156
156
|
}
|
|
157
157
|
end
|
|
158
158
|
|
data/lib/omniauth-lastfm.rb
CHANGED
data/omniauth-lastfm.gemspec
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
lib = File.expand_path(
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
-
require
|
|
5
|
+
require "omniauth/lastfm/version"
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name =
|
|
8
|
+
spec.name = "omniauth-lastfm"
|
|
9
9
|
spec.version = OmniAuth::Lastfm::VERSION
|
|
10
|
-
spec.authors = [
|
|
11
|
-
spec.email = [
|
|
10
|
+
spec.authors = ["Claudio Poli"]
|
|
11
|
+
spec.email = ["masterkain@gmail.com"]
|
|
12
12
|
|
|
13
|
-
spec.summary =
|
|
14
|
-
spec.description =
|
|
15
|
-
spec.homepage =
|
|
16
|
-
spec.license =
|
|
17
|
-
spec.required_ruby_version =
|
|
13
|
+
spec.summary = "OmniAuth strategy for Last.fm authentication."
|
|
14
|
+
spec.description = "OAuth strategy for OmniAuth that authenticates users with Last.fm and exposes profile metadata."
|
|
15
|
+
spec.homepage = "https://github.com/icoretech/omniauth-lastfm"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
spec.required_ruby_version = ">= 3.2"
|
|
18
18
|
|
|
19
|
-
spec.metadata[
|
|
20
|
-
spec.metadata[
|
|
21
|
-
spec.metadata[
|
|
22
|
-
spec.metadata[
|
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/icoretech/omniauth-lastfm"
|
|
20
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/icoretech/omniauth-lastfm/issues"
|
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/icoretech/omniauth-lastfm/releases"
|
|
22
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
23
23
|
|
|
24
24
|
spec.files = Dir[
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
"lib/**/*.rb",
|
|
26
|
+
"README*",
|
|
27
|
+
"LICENSE*",
|
|
28
|
+
"*.gemspec"
|
|
29
29
|
]
|
|
30
|
-
spec.require_paths = [
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
31
|
|
|
32
|
-
spec.add_dependency
|
|
32
|
+
spec.add_dependency "omniauth", ">= 2.1", "< 3.0"
|
|
33
33
|
end
|