diff --git a/.rubocop.yml b/.rubocop.yml index 4fa8e53..1e1a108 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,8 +8,11 @@ Layout/LineLength: Metrics/BlockLength: Exclude: - - spec/omniauth/strategies/tinkoff_id_spec.rb + - spec/omniauth/strategies/t_id_spec.rb Naming/FileName: Exclude: - - lib/omniauth-tinkoff-id.rb + - lib/omniauth-t-id.rb + +Gemspec/RequireMFA: + Enabled: false diff --git a/README.md b/README.md index 70811ca..b160278 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TinkoffId OAuth strategy for OmniAuth +# T-Id OAuth strategy for OmniAuth [![Ruby](https://github.com/foxford/omniauth-tinkoff-id/actions/workflows/main.yml/badge.svg)](https://github.com/foxford/omniauth-tinkoff-id/actions/workflows/main.yml) @@ -18,14 +18,14 @@ This gem already added. gem "omniauth-tinkoff-id" -[Join](https://tinkoff.github.io/tinkoff-id/join/) to TinkoffId +[Join](https://tinkoff.github.io/tinkoff-id/join/) to T-Id ### Usage -1. Add to omniauth.rb tinkoff_id provider: +1. Add to omniauth.rb t_id provider: Rails.application.config.middleware.use OmniAuth::Builder do - provider :tinkoff_id, ENV['TINKOFF_CLIENT_ID'], ENV['TINKOFF_CLIENT_SECRET'] + provider :t_id, ENV['TINKOFF_CLIENT_ID'], ENV['TINKOFF_CLIENT_SECRET'] end 2. Add route @@ -74,4 +74,4 @@ This project is licensed under the [MIT License](LICENSE.txt). ## Acknowledgments -* https://tinkoff.github.io/tinkoff-id/ +* https://developer.tbank.ru/docs/intro/partner/tid diff --git a/lib/omniauth-tinkoff-id.rb b/lib/omniauth-t-id.rb similarity index 50% rename from lib/omniauth-tinkoff-id.rb rename to lib/omniauth-t-id.rb index 404fc81..7618d3c 100644 --- a/lib/omniauth-tinkoff-id.rb +++ b/lib/omniauth-t-id.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'omniauth/tinkoff_id' +require 'omniauth/t_id' diff --git a/lib/omniauth/strategies/tinkoff_id.rb b/lib/omniauth/strategies/t_id.rb similarity index 85% rename from lib/omniauth/strategies/tinkoff_id.rb rename to lib/omniauth/strategies/t_id.rb index 3feaea2..7c606df 100644 --- a/lib/omniauth/strategies/tinkoff_id.rb +++ b/lib/omniauth/strategies/t_id.rb @@ -4,13 +4,13 @@ module OmniAuth module Strategies - # Authenticate to Tinkoff ID utilizing OAuth 2.0 - # https://tinkoff.github.io/tinkoff-id/ - class TinkoffId < OmniAuth::Strategies::OAuth2 - option :name, 'tinkoff_id' + # Authenticate to T-ID utilizing OAuth 2.0 + # https://developer.tbank.ru/docs/api/t-id + class TId < OmniAuth::Strategies::OAuth2 + option :name, 't_id' option :client_options, { - site: 'https://id.tinkoff.ru', + site: 'https://id.tbank.ru', token_url: '/auth/token', authorize_url: '/auth/authorize', auth_scheme: :basic_auth @@ -64,7 +64,7 @@ def verified_email end def connection - @connection ||= Faraday.new('https://id.tinkoff.ru') do |conn| + @connection ||= Faraday.new('https://id.tbank.ru') do |conn| conn.request :url_encoded conn.request :authorization, 'Bearer', access_token.token conn.response :json diff --git a/lib/omniauth/t_id.rb b/lib/omniauth/t_id.rb new file mode 100644 index 0000000..934e12c --- /dev/null +++ b/lib/omniauth/t_id.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require 'omniauth/strategies/t_id' diff --git a/lib/omniauth/tinkoff_id/version.rb b/lib/omniauth/t_id/version.rb similarity index 80% rename from lib/omniauth/tinkoff_id/version.rb rename to lib/omniauth/t_id/version.rb index 51bbf6c..2352197 100644 --- a/lib/omniauth/tinkoff_id/version.rb +++ b/lib/omniauth/t_id/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Omniauth - module TinkoffId + module TId VERSION = '0.1.0' end end diff --git a/lib/omniauth/tinkoff_id.rb b/lib/omniauth/tinkoff_id.rb deleted file mode 100644 index 5961e22..0000000 --- a/lib/omniauth/tinkoff_id.rb +++ /dev/null @@ -1,3 +0,0 @@ -# frozen_string_literal: true - -require 'omniauth/strategies/tinkoff_id' diff --git a/omniauth-tinkoff-id.gemspec b/omniauth-t-id.gemspec similarity index 53% rename from omniauth-tinkoff-id.gemspec rename to omniauth-t-id.gemspec index ccee8a6..11dea89 100644 --- a/omniauth-tinkoff-id.gemspec +++ b/omniauth-t-id.gemspec @@ -1,20 +1,20 @@ # frozen_string_literal: true -require_relative 'lib/omniauth/tinkoff_id/version' +require_relative 'lib/omniauth/t_id/version' Gem::Specification.new do |spec| - spec.name = 'omniauth-tinkoff-id' - spec.version = Omniauth::TinkoffId::VERSION + spec.name = 'omniauth-t-id' + spec.version = Omniauth::TId::VERSION spec.authors = ['Yury Druzhkov'] spec.email = ['bad1lamer@gmail.com'] - spec.summary = 'TinkoffId OAuth2 Strategy for OmniAuth' - spec.homepage = 'https://github.com/foxford/omniauth-tinkoff-id' + spec.summary = 'T-Id OAuth2 Strategy for OmniAuth' + spec.homepage = 'https://github.com/foxford/omniauth-t-id' spec.license = 'MIT' spec.required_ruby_version = '>= 2.7.0' spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } spec.files = `git ls-files`.split("\n") spec.require_paths = ['lib'] - spec.add_runtime_dependency 'omniauth-oauth2', '>= 1.5', '<= 1.8.0' + spec.add_dependency 'omniauth-oauth2', '>= 1.5', '<= 1.8.0' end diff --git a/spec/omniauth/strategies/tinkoff_id_spec.rb b/spec/omniauth/strategies/t_id_spec.rb similarity index 96% rename from spec/omniauth/strategies/tinkoff_id_spec.rb rename to spec/omniauth/strategies/t_id_spec.rb index 21b4dd1..a50bd8e 100644 --- a/spec/omniauth/strategies/tinkoff_id_spec.rb +++ b/spec/omniauth/strategies/t_id_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe OmniAuth::Strategies::TinkoffId do +describe OmniAuth::Strategies::TId do subject do described_class.new(app, 'client_id', 'client_secret', @options || {}).tap do |strategy| allow(strategy).to receive(:request) do @@ -28,7 +28,7 @@ describe '#client_options' do it 'has correct site' do - expect(subject.client.site).to eq('https://id.tinkoff.ru') + expect(subject.client.site).to eq('https://id.tbank.ru') end it 'has correct authorize_url' do @@ -82,13 +82,13 @@ it 'returns correct default callback path' do allow(subject).to receive(:full_host) { base_url } allow(subject).to receive(:script_name).and_return('') - expect(subject.send(:callback_url)).to eq("#{base_url}/auth/tinkoff_id/callback") + expect(subject.send(:callback_url)).to eq("#{base_url}/auth/t_id/callback") end it 'sets the callback path with script_name if present' do allow(subject).to receive(:full_host) { base_url } allow(subject).to receive(:script_name).and_return('/v1') - expect(subject.send(:callback_url)).to eq("#{base_url}/v1/auth/tinkoff_id/callback") + expect(subject.send(:callback_url)).to eq("#{base_url}/v1/auth/t_id/callback") end it 'sets the callback_path parameter if present' do @@ -129,7 +129,7 @@ end before do - stub_request(:post, 'https://id.tinkoff.ru/userinfo/userinfo') + stub_request(:post, 'https://id.tbank.ru/userinfo/userinfo') .with( body: { 'client_id' => 'client_id', 'client_secret' => 'client_secret' }, headers: { diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 52708ae..1c2878e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,7 @@ require 'rspec' require 'webmock/rspec' require 'omniauth' -require 'omniauth/strategies/tinkoff_id' +require 'omniauth/strategies/t_id' RSpec.configure do |config| config.include WebMock::API