Class: OpenIDConnect::Client::Registrar
- Inherits:
-
Object
- Object
- OpenIDConnect::Client::Registrar
show all
- Includes:
- ActiveModel::Validations, AttrOptional, AttrRequired
- Defined in:
- lib/openid_connect/client/registrar.rb
Defined Under Namespace
Classes: RegistrationFailed
Instance Method Summary
collapse
Constructor Details
#initialize(endpoint, attributes = {}) ⇒ Registrar
Returns a new instance of Registrar.
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/openid_connect/client/registrar.rb', line 85
def initialize(endpoint, attributes = {})
@endpoint = endpoint
optional_attributes.each do |_attr_|
value = if _attr_ == :access_token
attributes[_attr_]
else
attributes[_attr_].try(:to_s)
end
self.send "#{_attr_}=", value
end
attr_missing!
end
|
Instance Method Details
#as_json(options = {}) ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/openid_connect/client/registrar.rb', line 117
def as_json(options = {})
validate!
(optional_attributes - [:access_token]).inject({}) do |hash, _attr_|
value = self.send(_attr_)
hash.merge! _attr_ => case value
when Array
value.collect(&:to_s).join(' ')
else
value
end
end.delete_if do |key, value|
value.nil?
end
end
|
#associate! ⇒ Object
132
133
134
135
|
# File 'lib/openid_connect/client/registrar.rb', line 132
def associate!
self.type = 'client_associate'
post!
end
|
#rotate_secret! ⇒ Object
137
138
139
140
|
# File 'lib/openid_connect/client/registrar.rb', line 137
def rotate_secret!
self.type = 'rotate_secret'
post!
end
|
#sector_identifier ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/openid_connect/client/registrar.rb', line 98
def sector_identifier
if valid_uri?(sector_identifier_url)
URI.parse(sector_identifier_url).host
else
hosts = Array(redirect_uris).collect do |redirect_uri|
if valid_uri?(redirect_uri, nil)
URI.parse(redirect_uri).host
else
nil
end
end.compact.uniq
if hosts.size == 1
hosts.first
else
nil
end
end
end
|
#update! ⇒ Object
142
143
144
145
|
# File 'lib/openid_connect/client/registrar.rb', line 142
def update!
self.type = 'client_update'
post!
end
|
#validate! ⇒ Object
147
148
149
|
# File 'lib/openid_connect/client/registrar.rb', line 147
def validate!
valid? or raise ValidationFailed.new(self)
end
|