Class: OmniAuth::Strategies::Latvija
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::Latvija
show all
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/latvija.rb,
lib/omniauth/strategies/latvija/response.rb,
lib/omniauth/strategies/latvija/decryptor.rb,
lib/omniauth/strategies/latvija/signed_document.rb
Overview
Authenticate with Latvija.lv.
Defined Under Namespace
Classes: Decryptor, Response, SignedDocument, ValidationError
Instance Method Summary
collapse
Instance Method Details
#callback_phase ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/omniauth/strategies/latvija.rb', line 69
def callback_phase
if request.params['wresult']
@response = OmniAuth::Strategies::Latvija::Response.new(
request.params['wresult'],
certificate: options[:certificate],
private_key: options[:private_key]
)
@response.validate!
super
else
fail!(:invalid_response)
end
rescue Exception => e
fail!(:invalid_response, e)
end
|
#full_name ⇒ Object
93
94
95
|
# File 'lib/omniauth/strategies/latvija.rb', line 93
def full_name
@full_name ||= "#{raw_info['givenname']} #{raw_info['surname']}"
end
|
#legacy_uids ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/omniauth/strategies/latvija.rb', line 97
def legacy_uids
legacy_uids = [
"#{full_name}, #{raw_info["privatepersonalidentifier"]}" ]
raw_info.fetch('historical_privatepersonalidentifier', []).each do |historical_identifier|
legacy_uids << "#{full_name}, #{historical_identifier}" legacy_uids << "PK:#{historical_identifier}" end
legacy_uids
end
|
#raw_info ⇒ Object
85
86
87
|
# File 'lib/omniauth/strategies/latvija.rb', line 85
def raw_info
@response.attributes
end
|
#request_phase ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/omniauth/strategies/latvija.rb', line 55
def request_phase
params = {
wa: 'wsignin1.0',
wct: Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ'),
wtrealm: options[:realm],
wreply: callback_url,
wctx: callback_url,
wreq: '<trust:RequestSecurityToken xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512"><trust:Claims xmlns:i="http://schemas.xmlsoap.org/ws/2005/05/identity" Dialect="http://schemas.xmlsoap.org/ws/2005/05/identity"><i:ClaimType Uri="http://docs.oasis-open.org/wsfed/authorization/200706/claims/action" Optional="false" /></trust:Claims><trust:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</trust:RequestType></trust:RequestSecurityToken>'
}
params[:wfresh] = options[:wfresh] if options[:wfresh]
query_string = params.collect { |key, value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&')
redirect "#{options[:endpoint]}?#{query_string}"
end
|
#uid ⇒ Object
89
90
91
|
# File 'lib/omniauth/strategies/latvija.rb', line 89
def uid
@response.name_identifier
end
|