cmpa_auth 1.0.5 → 1.0.6
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.
- data/CHANGELOG.rdoc +4 -0
- data/lib/cmpa_auth.rb +1 -0
- data/lib/cmpa_auth/authentication.rb +17 -7
- data/lib/cmpa_auth/models/grupo_acesso.rb +1 -4
- data/lib/cmpa_auth/models/lotacao_temporaria.rb +1 -5
- data/lib/cmpa_auth/models/pessoa.rb +1 -11
- data/lib/cmpa_auth/models/setor.rb +0 -3
- data/lib/cmpa_auth/models/sistema.rb +1 -5
- metadata +27 -7
data/CHANGELOG.rdoc
CHANGED
data/lib/cmpa_auth.rb
CHANGED
@@ -3,13 +3,23 @@ module CmpaAuth
|
|
3
3
|
|
4
4
|
CLASS_NAMES = %w( Pessoa Estagiario Funcionario GrupoAcesso LotacaoTemporaria Setor Sistema )
|
5
5
|
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
# Realiza a autenticação via LDAP. Se a autenticação for bem sucedida é realizada uma
|
7
|
+
# consulta pelo +username+ na tabela +pessoas+ e uma instância de +Pessoa+ é retornada.
|
8
|
+
# Caso contrário, retorna +nil+.
|
9
|
+
def self.authenticate(username, password)
|
10
|
+
ldap_options = {
|
11
|
+
:host => '200.169.19.93',
|
12
|
+
:port => 389,
|
13
|
+
:base => 'DC=cmpa,DC=local',
|
14
|
+
:auth => {
|
15
|
+
:method => :simple,
|
16
|
+
:username => "#{username}@cmpa.local",
|
17
|
+
:password => password
|
18
|
+
}
|
19
|
+
}
|
20
|
+
Net::LDAP.open ldap_options do |ldap|
|
21
|
+
Pessoa.first(:conditions => { :username => username }) if ldap.bind
|
22
|
+
end
|
13
23
|
end
|
14
24
|
|
15
25
|
#
|
@@ -3,12 +3,9 @@ module CmpaAuth
|
|
3
3
|
module GrupoAcesso
|
4
4
|
def self.included(receiver) #:nodoc:
|
5
5
|
receiver.class_eval do
|
6
|
-
|
7
|
-
include CmpaAuth::PortalConnection
|
8
|
-
|
6
|
+
include CmpaAuth::PortalConnection
|
9
7
|
has_and_belongs_to_many :lotacoes_temporarias, :join_table => :grupoacessos_lotacoestemporarias, :foreign_key => :grupoacesso_id, :association_foreign_key => :lotacoestemporaria_id, :class_name => '::LotacaoTemporaria'
|
10
8
|
has_and_belongs_to_many :sistemas, :join_table => :grupoacessos_sistemas, :foreign_key => :grupoacesso_id, :class_name => '::Sistema'
|
11
|
-
|
12
9
|
set_table_name :grupoacessos
|
13
10
|
end
|
14
11
|
end
|
@@ -3,14 +3,10 @@ module CmpaAuth
|
|
3
3
|
module LotacaoTemporaria
|
4
4
|
def self.included(receiver) #:nodoc:
|
5
5
|
receiver.class_eval do
|
6
|
-
|
7
|
-
include CmpaAuth::PortalConnection
|
8
|
-
|
6
|
+
include CmpaAuth::PortalConnection
|
9
7
|
belongs_to :setor, :class_name => '::Setor'
|
10
8
|
belongs_to :pessoa, :class_name => '::Pessoa'
|
11
|
-
|
12
9
|
has_and_belongs_to_many :grupos_acesso, :join_table => :grupoacessos_lotacoestemporarias, :foreign_key => :lotacoestemporaria_id, :association_foreign_key => :grupoacesso_id, :class_name => '::GrupoAcesso'
|
13
|
-
|
14
10
|
set_table_name :lotacoestemporarias
|
15
11
|
|
16
12
|
#
|
@@ -3,24 +3,14 @@ module CmpaAuth
|
|
3
3
|
module Pessoa
|
4
4
|
def self.included(receiver) #:nodoc:
|
5
5
|
receiver.class_eval do
|
6
|
-
|
7
6
|
include CmpaAuth::PortalConnection
|
8
|
-
|
9
7
|
set_table_name :pessoas
|
10
8
|
|
11
9
|
def lotacoes_temporarias_ativas
|
12
10
|
::LotacaoTemporaria.scoped(:conditions => {:fim => nil, :pessoa_id => id})
|
13
11
|
end
|
14
|
-
|
15
|
-
def senha=(pass)
|
16
|
-
if pass != "senhaantiga" && pass.present?
|
17
|
-
salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
|
18
|
-
self.senha_salt = salt
|
19
|
-
self.senha_hash = Digest::SHA256.hexdigest(pass + salt)
|
20
|
-
end
|
21
|
-
end
|
22
12
|
end
|
23
13
|
end
|
24
14
|
end
|
25
15
|
end
|
26
|
-
end
|
16
|
+
end
|
@@ -3,12 +3,9 @@ module CmpaAuth
|
|
3
3
|
module Setor
|
4
4
|
def self.included(receiver) #:nodoc:
|
5
5
|
receiver.class_eval do
|
6
|
-
|
7
6
|
include CmpaAuth::PortalConnection
|
8
|
-
|
9
7
|
has_many :lotacoes_temporarias, :foreign_key => :setor_id, :class_name => '::LotacaoTemporaria'
|
10
8
|
has_many :funcionarios, :through => :lotacoes_temporarias, :source => :pessoa
|
11
|
-
|
12
9
|
set_table_name :setores
|
13
10
|
end
|
14
11
|
end
|
@@ -3,13 +3,9 @@ module CmpaAuth
|
|
3
3
|
module Sistema
|
4
4
|
def self.included(receiver) #:nodoc:
|
5
5
|
receiver.class_eval do
|
6
|
-
|
7
|
-
include CmpaAuth::PortalConnection
|
8
|
-
|
6
|
+
include CmpaAuth::PortalConnection
|
9
7
|
default_scope :order => :nome
|
10
|
-
|
11
8
|
has_and_belongs_to_many :grupos_acesso, :join_table => :grupoacessos_sistemas, :association_foreign_key => :grupoacesso_id, :class_name => '::GrupoAcesso'
|
12
|
-
|
13
9
|
set_table_name :sistemas
|
14
10
|
end
|
15
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmpa_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
version: 1.0.6
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- "CMPA Assessoria de Inform\xC3\xA1tica"
|
@@ -9,10 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-15 00:00:00 -03:00
|
13
18
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: net-ldap
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 1
|
30
|
+
- 1
|
31
|
+
version: 0.1.1
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
16
34
|
description: "Biblioteca de autentica\xC3\xA7\xC3\xA3o para a Assessoria de Inform\xC3\xA1tica (CMPA)."
|
17
35
|
email: icaro.ldm@gmail.com
|
18
36
|
executables: []
|
@@ -88,18 +106,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
106
|
requirements:
|
89
107
|
- - ">="
|
90
108
|
- !ruby/object:Gem::Version
|
109
|
+
segments:
|
110
|
+
- 0
|
91
111
|
version: "0"
|
92
|
-
version:
|
93
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
113
|
requirements:
|
95
114
|
- - ">="
|
96
115
|
- !ruby/object:Gem::Version
|
116
|
+
segments:
|
117
|
+
- 0
|
97
118
|
version: "0"
|
98
|
-
version:
|
99
119
|
requirements: []
|
100
120
|
|
101
121
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.3.
|
122
|
+
rubygems_version: 1.3.6
|
103
123
|
signing_key:
|
104
124
|
specification_version: 3
|
105
125
|
summary: "Adiciona uma solu\xC3\xA7\xC3\xA3o completa de autentica\xC3\xA7\xC3\xA3o e permiss\xC3\xB5es."
|