diaspora/app/controllers/openid_connect/clients_controller.rb
theworldbright 88d02ea35b Add client registration
Client must now be registered prior to imitating a
call to the token endpoint with the password flow.

Squashed commits:

[fdcef62] Rename authorization endpoint to protected resource endpoint
2016-01-04 16:49:48 +09:00

30 lines
787 B
Ruby

class OpenidConnect::ClientsController < ApplicationController
rescue_from OpenIDConnect::HttpError do |e|
rewriteHTTPErrorPageAsJSON(e)
end
rescue_from OpenIDConnect::ValidationFailed do |e|
rewriteValidationFailErrorPageAsJSON(e)
end
def create
registrar = OpenIDConnect::Client::Registrar.new(request.url, params)
client = OAuthApplication.register! registrar
render json: client
end
private
def rewriteHTTPErrorPageAsJSON(e)
render json: {
error: :invalid_request,
error_description: e.message
}, status: 400
end
def rewriteValidationFailErrorPageAsJSON(e)
render json: {
error: :invalid_client_metadata,
error_description: e.message
}, status: 400
end
end