auth-service-authenticator 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eed44b8e2547842a1dfde4a5cf7aa89229c723fa
4
- data.tar.gz: 881d3ee75fb9b0e69862eab14196b91a7468b990
3
+ metadata.gz: d2702ae80932f8f388287ae9b03d37c349505887
4
+ data.tar.gz: c773ed43fc21eeba4afa9466464a70d99c7b919e
5
5
  SHA512:
6
- metadata.gz: 4621a47af6b11bb26a6e139029efd63fb634b47e06308bcf97ae58c0e5890959482746591c2abe11af40bb8efbc9a1799f23076d6a84c37c91f67655e2a65a35
7
- data.tar.gz: db04c7220e17410173aea965facb1c3716440d169f571a1f57a91dc5f1f7ff4a250e76e43ffabcae1ccc163255569681d608bf90db636b9b4e5c4d8e2f6a2be5
6
+ metadata.gz: 0b50d1943abff5150179a67add60bf35873a148fc17a7c1bf8d80b3bd16cebd505574fbb9b8ebe47b1d5dfe67a51eb5c0a0553914e2001bc5802704e0c619fbc
7
+ data.tar.gz: 8c24ceca0ec451e58f1d4a4ecb761abdcfd209b66e91b98291cbf1532dd6798f6a85d12423ced277122fca83b56158c0ab335e030111eb976c2f1c56880832ce
data/README.md CHANGED
@@ -11,13 +11,20 @@ Adicione essa linha ao seu Gemfile:
11
11
  gem 'auth-service-authenticator'
12
12
  ```
13
13
 
14
- Agora execute:
14
+ na pasta `config` crie um arquivo com o nome `authenticator_config.yml` e adicione as chaves:
15
+ ```ruby
16
+ url: URL_DO_SERVICO_DE_AUTENTICACAO
17
+ port: PORTA_DO_SERVICE_DE_AUTENTICACAO
18
+ ```
15
19
 
16
- $ bundle install
20
+ Agora execute:
21
+ ```sh
22
+ $ bundle install
23
+ ```
17
24
 
18
25
  ## Como Utilizar
19
26
 
20
- Utilize os metodos `authenticate` e `validate_token`:
27
+ Utilize os metodos `authenticate` e `validate_token` e `logout`:
21
28
  ```ruby
22
29
  # Autentique o usuário fonecendo o email e senha
23
30
  response = Auth::Service::Authenticator::Manager.authenticate('EMAIL', 'SENHA')
@@ -63,6 +70,9 @@ Utilize os metodos `authenticate` e `validate_token`:
63
70
 
64
71
  # Caso o token seja válido, continue com sua aplicação normalmente.
65
72
  # Caso inválido, redirecione o usuário para página de login.
73
+
74
+ # Logout do usuário
75
+ response = Auth::Service::Authenticator::Manager.logout('TOKEN')
66
76
  ```
67
77
 
68
78
  ## Development
@@ -56,6 +56,27 @@ module Auth
56
56
  return result
57
57
  end
58
58
 
59
+ def self.logout(token)
60
+ uri = URI.parse("#{@@auth_url}")
61
+ http = Net::HTTP.new(@@auth_url, @@auth_port)
62
+ request = Net::HTTP::Delete.new("/api/v1/authenticate")
63
+ request.add_field('Content-Type', 'application/json')
64
+ request.add_field('Authorization', token)
65
+ response = http.request(request)
66
+
67
+ result = case response
68
+ when Net::HTTPNoContent then
69
+ { status: response.code, message: 'success', success: true }
70
+ when Net::HTTPClientError then
71
+ { error: 'Token invalido.', status: response.code, message: response.message }
72
+ when Net::ReadTimeout then
73
+ { error: 'timeout', status: response.code, message: response.message }
74
+ else
75
+ { error: 'erro inesperado. tente novamente mais tarde.', status: '422', message: '' }
76
+ end
77
+ return result
78
+ end
79
+
59
80
  private
60
81
  # Setup auth server configuration
61
82
  def self.configure
@@ -1,7 +1,7 @@
1
1
  module Auth
2
2
  module Service
3
3
  module Authenticator
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth-service-authenticator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Paulino
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-29 00:00:00.000000000 Z
11
+ date: 2017-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler