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.
62
63
64
65
66
67
68
|
# File 'lib/openid_connect/client/registrar.rb', line 62
def initialize(endpoint, attributes = {})
self.endpoint = endpoint
self.initial_access_token = attributes[:initial_access_token]
self.class.metadata_attributes.each do |_attr_|
self.send "#{_attr_}=", attributes[_attr_]
end
end
|
Instance Method Details
#as_json(options = {}) ⇒ Object
89
90
91
92
93
94
95
96
|
# File 'lib/openid_connect/client/registrar.rb', line 89
def as_json(options = {})
validate!
self.class.metadata_attributes.inject({}) do |hash, _attr_|
value = self.send _attr_
hash.merge! _attr_ => value unless value.nil?
hash
end
end
|
#read ⇒ Object
104
105
106
|
# File 'lib/openid_connect/client/registrar.rb', line 104
def read
end
|
#register! ⇒ Object
98
99
100
101
102
|
# File 'lib/openid_connect/client/registrar.rb', line 98
def register!
handle_response do
http_client.post endpoint, to_json, 'Content-Type' => 'application/json'
end
end
|
#sector_identifier ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/openid_connect/client/registrar.rb', line 70
def sector_identifier
if valid_uri?(sector_identifier_uri)
URI.parse(sector_identifier_uri).host
else
hosts = 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
|
#validate! ⇒ Object
108
109
110
|
# File 'lib/openid_connect/client/registrar.rb', line 108
def validate!
valid? or raise ValidationFailed.new(self)
end
|