Move openid controllers to openid connect namespace
This commit is contained in:
parent
52e10a91fe
commit
3fc0f64c56
7 changed files with 17 additions and 22 deletions
2
Gemfile
2
Gemfile
|
|
@ -150,7 +150,7 @@ gem "twitter", "5.15.0"
|
||||||
gem "omniauth-wordpress", "0.2.2"
|
gem "omniauth-wordpress", "0.2.2"
|
||||||
|
|
||||||
# OpenID Connect
|
# OpenID Connect
|
||||||
gem "openid_connect"
|
gem "openid_connect", "0.8.3"
|
||||||
|
|
||||||
# Serializers
|
# Serializers
|
||||||
|
|
||||||
|
|
|
||||||
14
Gemfile.lock
14
Gemfile.lock
|
|
@ -522,17 +522,17 @@ GEM
|
||||||
open_graph_reader (0.6.1)
|
open_graph_reader (0.6.1)
|
||||||
faraday (~> 0.9.0)
|
faraday (~> 0.9.0)
|
||||||
nokogiri (~> 1.6)
|
nokogiri (~> 1.6)
|
||||||
openid_connect (0.9.2)
|
openid_connect (0.8.3)
|
||||||
activemodel
|
activemodel
|
||||||
attr_required (>= 1.0.0)
|
attr_required (>= 0.0.5)
|
||||||
json (>= 1.4.3)
|
json (>= 1.4.3)
|
||||||
json-jwt (>= 1.5.0)
|
json-jwt (>= 0.5.5)
|
||||||
rack-oauth2 (>= 1.2.1)
|
rack-oauth2 (>= 1.0.0)
|
||||||
swd (>= 1.0.0)
|
swd (>= 0.1.2)
|
||||||
tzinfo
|
tzinfo
|
||||||
validate_email
|
validate_email
|
||||||
validate_url
|
validate_url
|
||||||
webfinger (>= 1.0.1)
|
webfinger (>= 0.0.2)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
parser (2.2.3.0)
|
parser (2.2.3.0)
|
||||||
ast (>= 1.1, < 3.0)
|
ast (>= 1.1, < 3.0)
|
||||||
|
|
@ -942,7 +942,7 @@ DEPENDENCIES
|
||||||
omniauth-twitter (= 1.2.1)
|
omniauth-twitter (= 1.2.1)
|
||||||
omniauth-wordpress (= 0.2.2)
|
omniauth-wordpress (= 0.2.2)
|
||||||
open_graph_reader (= 0.6.1)
|
open_graph_reader (= 0.6.1)
|
||||||
openid_connect
|
openid_connect (= 0.8.3)
|
||||||
pg (= 0.18.4)
|
pg (= 0.18.4)
|
||||||
pronto (= 0.5.3)
|
pronto (= 0.5.3)
|
||||||
pronto-haml (= 0.5.0)
|
pronto-haml (= 0.5.0)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
class ConnectController < ApplicationController
|
|
||||||
def show
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -5,31 +5,31 @@ class AuthorizationsController < ApplicationController
|
||||||
render :error, status: e.status
|
render :error, status: e.status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def new
|
def new
|
||||||
call_authorization_endpoint
|
call_authorization_endpoint
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
call_authorization_endpoint :allow_approval, params[:approve]
|
call_authorization_endpoint :is_create, params[:approve]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def call_authorization_endpoint(allow_approval = false, approved = false)
|
def call_authorization_endpoint(is_create = false, approved = false)
|
||||||
endpoint = AuthorizationEndpoint.new allow_approval, approved
|
endpoint = AuthorizationEndpoint.new current_user, is_create, approved
|
||||||
rack_response = *endpoint.call(request.env)
|
rack_response = *endpoint.call(request.env)
|
||||||
@client, @response_type, @redirect_uri, @scopes, @_request_, @request_uri, @request_object = *[
|
@client, @response_type, @redirect_uri, @scopes, @_request_, @request_uri, @request_object = *[
|
||||||
endpoint.client, endpoint.response_type, endpoint.redirect_uri, endpoint.scopes, endpoint._request_, endpoint.request_uri, endpoint.request_object
|
endpoint.client, endpoint.response_type, endpoint.redirect_uri, endpoint.scopes, endpoint._request_, endpoint.request_uri, endpoint.request_object
|
||||||
]
|
]
|
||||||
require_authentication
|
|
||||||
if (
|
if (
|
||||||
!allow_approval &&
|
!is_create &&
|
||||||
(max_age = @request_object.try(:id_token).try(:max_age)) &&
|
(max_age = @request_object.try(:id_token).try(:max_age)) &&
|
||||||
current_account.last_logged_in_at < max_age.seconds.ago
|
current_account.last_logged_in_at < max_age.seconds.ago
|
||||||
)
|
)
|
||||||
flash[:notice] = 'Exceeded Max Age, Login Again'
|
flash[:notice] = 'Exceeded Max Age, Login Again'
|
||||||
unauthenticate!
|
unauthenticate!
|
||||||
require_authentication
|
|
||||||
end
|
end
|
||||||
respond_as_rack_app *rack_response
|
respond_as_rack_app *rack_response
|
||||||
end
|
end
|
||||||
|
|
@ -234,14 +234,13 @@ Diaspora::Application.routes.draw do
|
||||||
root :to => 'home#show'
|
root :to => 'home#show'
|
||||||
|
|
||||||
#OpenID Connect & OAuth
|
#OpenID Connect & OAuth
|
||||||
resource :openid do
|
namespace :openid_connect do
|
||||||
|
resources :clients, only: :create
|
||||||
resources :authorizations, only: [:new, :create]
|
resources :authorizations, only: [:new, :create]
|
||||||
match 'connect', to: 'connect#show', via: [:get, :post]
|
|
||||||
match '.well-known/:id', to: 'discovery#show' , via: [:get, :post]
|
|
||||||
post 'access_tokens', to: proc { |env| OpenidConnect::TokenEndpoint.new.call(env) }
|
post 'access_tokens', to: proc { |env| OpenidConnect::TokenEndpoint.new.call(env) }
|
||||||
end
|
end
|
||||||
|
|
||||||
api_version(module: "Api::V0", path: {value: "api/v0"}, default: true) do
|
api_version(module: "Api::V0", path: {value: "api/v0"}, default: true) do
|
||||||
match 'user', to: 'users#show', via: :get
|
match 'user', to: 'users#show', via: [:get, :post]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue