omniauth-shikimori-oauth2 1.0.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: ea04efed2f5b8f6ca5175c9f2ab0620971c6026a42e41c693a4b0744b7414150
4
+ data.tar.gz: 7bdc09bf37f87db1ad37317b072833dc1831a998a4d70c9080fc40190afd2568
5
+ SHA512:
6
+ metadata.gz: '07392bb0a496168eac6d7c920b681071381feff7e1ebeb4d9d500b344fa48f7aa16bc5e8f47f571c5b4f12d7d3b802e435537f8b2954ac5d192f47f942b8f581'
7
+ data.tar.gz: 3efdae723a41f72409328e153f12a97a4927da1935b646c3155ae9f1627b02d49ea779b82a1be1ea4534e84fa63d545165042eff6c616a051e1937cdcd0f8890
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ [![CI](https://github.com/iwdt/shikikit/actions/workflows/main.yml/badge.svg)](https://github.com/iwdt/shikikit/actions/workflows/main.yml) [![codecov](https://codecov.io/gh/iwdt/shikikit/graph/badge.svg)](https://codecov.io/gh/iwdt/shikikit)
2
+
3
+ # Shikikit
4
+ Ruby toolkit for the [Shikimori API](https://shikimori.one)
5
+
6
+ ## TODO:
7
+ - logger
8
+ - #as_app
9
+ - proxy config
10
+ - oauth methods on API
11
+ - optional auto refresh token
12
+ - more information at errors
13
+ - more tests
14
+ - entities for responses
15
+ - contracts for requests (client-side validations)
16
+ - better documentation
17
+ - mutator
18
+ - CI/CD
19
+ - auto version increment on main branch pushing
20
+ - deploy to rubygems
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Shikimori
5
+ # @return [String] Semantic version of library
6
+ VERSION = '1.0.0'
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'oauth2'
4
+ require 'omniauth/strategies/oauth2'
5
+ require 'shikimori-oauth2'
6
+
7
+ require_relative 'shikimori/version'
8
+ require_relative 'strategies/shikimori'
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ # OmnAuth strategy for Shikimori
6
+ #
7
+ # @see https://github.com/omniauth/omniauth-oauth2 Official repository for OmniAuth OAuth2
8
+ class Shikimori < OAuth2
9
+ USER_INFO_PATH = 'api/users/whoami'
10
+
11
+ option :name, :shikimori
12
+ option :client_options, site: ::Shikimori::OAuth2::Config::DEFAULT_SITE_URL
13
+ option :app_name, ::Shikimori::OAuth2::Config::DEFAULT_APP_NAME
14
+
15
+ uid { raw_info['id'] }
16
+
17
+ info do
18
+ {
19
+ nickname: raw_info['nickname'],
20
+ name: raw_info['name'],
21
+ gender: raw_info['sex'],
22
+ locale: raw_info['locale'],
23
+ avatar_url: raw_info['avatar'],
24
+ website: raw_info['website'],
25
+ birthday: raw_info['birth_on'],
26
+ urls: { shikimori: raw_info['url'] }
27
+ }
28
+ end
29
+
30
+ def client
31
+ @client ||= ::Shikimori::OAuth2::Client.new(
32
+ options.client_id,
33
+ options.client_secret,
34
+ deep_symbolize(options.client_options),
35
+ app_name: options.app_name
36
+ )
37
+ end
38
+
39
+ def raw_info
40
+ @raw_info ||= access_token.get(info_uri).parsed
41
+ end
42
+
43
+ private
44
+
45
+ def info_uri
46
+ URI.join(client.site, USER_INFO_PATH)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/shikimori'
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/omniauth/shikimori/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'omniauth-shikimori-oauth2'
7
+ spec.version = OmniAuth::Shikimori::VERSION
8
+ spec.authors = ['Ivan Naumov']
9
+ spec.email = ['ivannaymov@gmail.com']
10
+
11
+ spec.summary = 'OmnAuth strategy for Shikimori'
12
+ spec.description = 'Strategy to authenticate with Shikimori via OAuth2 in OmniAuth.'
13
+ spec.homepage = 'https://github.com/iwdt/shikikit'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.0'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
+ spec.metadata['source_code_uri'] = 'https://github.com/iwdt/shikikit'
20
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/iwdt/shikikit/issues'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/iwdt/shikikit/blob/main/CHANGELOG.md'
22
+ spec.metadata['rubygems_mfa_required'] = 'true'
23
+
24
+ spec.files = Dir[
25
+ # Common files
26
+ 'LICENSE',
27
+ 'README.md',
28
+ 'omniauth-shikimori-oauth2.gemspec',
29
+ # Code
30
+ 'lib/omniauth-shikimori-oauth2.rb',
31
+ 'lib/omniauth/**/*',
32
+ # Signatures
33
+ 'sig/omniauth/**/*'
34
+ ]
35
+ spec.bindir = 'bin'
36
+ spec.executables = []
37
+ spec.require_paths = ['lib']
38
+
39
+ spec.add_dependency 'omniauth-oauth2', '~> 1.8'
40
+ spec.add_dependency 'shikimori-oauth2', '~> 1.0.0'
41
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Shikimori
3
+ VERSION: String
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module OmniAuth
2
+ module Shikimori
3
+ end
4
+ end
@@ -0,0 +1,23 @@
1
+ module OmniAuth
2
+ module Strategies
3
+ class OAuth2
4
+ interface _Response
5
+ def parsed: () -> ::Hash[_ToS, Object]
6
+ end
7
+
8
+ interface _AccessToken
9
+ def get: (::URI::Generic) -> _Response
10
+ end
11
+
12
+ def self.option: (Symbol, ?Object) -> void
13
+ def self.uid: () { -> Object } -> void
14
+ def self.info: () { -> ::Hash[_ToS, Object] } -> void
15
+
16
+ @raw_info: ::Hash[String, Object]
17
+ def raw_info: -> ::Hash[_ToS, Object]
18
+ def self.raw_info: -> ::Hash[_ToS, Object]
19
+ def access_token: -> _AccessToken
20
+ def deep_symbolize: (::Hash[_ToS, Object]) -> ::Hash[_ToS, Object]
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module OmniAuth
2
+ module Strategies
3
+ class Shikimori < OAuth2
4
+ interface _Options
5
+ def client_id: -> String
6
+ def client_secret: -> String
7
+ def client_options: -> ::Hash[Symbol, Object]
8
+ def app_name: -> String
9
+ end
10
+
11
+ USER_INFO_PATH: String
12
+ @client: ::Shikimori::OAuth2::Client
13
+
14
+ attr_reader options: _Options
15
+ def client: -> ::Shikimori::OAuth2::Client
16
+
17
+ private
18
+
19
+ def info_uri: -> ::URI::Generic
20
+ end
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-shikimori-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ivan Naumov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: shikimori-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
41
+ description: Strategy to authenticate with Shikimori via OAuth2 in OmniAuth.
42
+ email:
43
+ - ivannaymov@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - README.md
49
+ - lib/omniauth-shikimori-oauth2.rb
50
+ - lib/omniauth/shikimori.rb
51
+ - lib/omniauth/shikimori/version.rb
52
+ - lib/omniauth/strategies/shikimori.rb
53
+ - omniauth-shikimori-oauth2.gemspec
54
+ - sig/omniauth/shikimori.rbs
55
+ - sig/omniauth/shikimori/version.rbs
56
+ - sig/omniauth/strategies/oauth2.rbs
57
+ - sig/omniauth/strategies/shikimori.rbs
58
+ homepage: https://github.com/iwdt/shikikit
59
+ licenses:
60
+ - MIT
61
+ metadata:
62
+ homepage_uri: https://github.com/iwdt/shikikit
63
+ allowed_push_host: https://rubygems.org
64
+ source_code_uri: https://github.com/iwdt/shikikit
65
+ bug_tracker_uri: https://github.com/iwdt/shikikit/issues
66
+ changelog_uri: https://github.com/iwdt/shikikit/blob/main/CHANGELOG.md
67
+ rubygems_mfa_required: 'true'
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '3.0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubygems_version: 3.0.3.1
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: OmnAuth strategy for Shikimori
87
+ test_files: []