Class: Api::OpenidConnect::OAuthApplication

Inherits:
ApplicationRecord show all
Defined in:
app/models/api/openid_connect/o_auth_application.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available_response_typesObject


64
65
66
# File 'app/models/api/openid_connect/o_auth_application.rb', line 64

def available_response_types
  ["id_token", "id_token token", "code"]
end

.register!(registrar) ⇒ Object


68
69
70
71
# File 'app/models/api/openid_connect/o_auth_application.rb', line 68

def register!(registrar)
  registrar.validate!
  build_client_application(registrar)
end

Instance Method Details

#as_json(opts = {}) ⇒ Object


47
48
49
50
51
52
# File 'app/models/api/openid_connect/o_auth_application.rb', line 47

def as_json(opts={})
  data = super
  data["client_secret_expires_at"] = 0
  data["token_endpoint_auth_method"] ||= "client_secret_post"
  data
end

#image_uriObject


59
60
61
# File 'app/models/api/openid_connect/o_auth_application.rb', line 59

def image_uri
  logo_uri ? Diaspora::Camo.image_url(logo_uri) : nil
end

#setupObject


54
55
56
57
# File 'app/models/api/openid_connect/o_auth_application.rb', line 54

def setup
  self.client_id = SecureRandom.hex(16)
  self.client_secret = SecureRandom.hex(32)
end