Skip to content

Commit

Permalink
Rebrading T-bank
Browse files Browse the repository at this point in the history
  • Loading branch information
badlamer committed Jul 24, 2024
1 parent 5469f83 commit faef0cd
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 31 deletions.
7 changes: 5 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/omniauth-tinkoff-id.rb → lib/omniauth-t-id.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

require 'omniauth/tinkoff_id'
require 'omniauth/t_id'
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/omniauth/t_id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require 'omniauth/strategies/t_id'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Omniauth
module TinkoffId
VERSION = '0.1.0'
module TId
VERSION = '0.2.0'
end
end
3 changes: 0 additions & 3 deletions lib/omniauth/tinkoff_id.rb

This file was deleted.

12 changes: 6 additions & 6 deletions omniauth-tinkoff-id.gemspec → omniauth-t-id.gemspec
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit faef0cd

Please sign in to comment.