Convert OpenID authentication to use OmniAuth
This commit is contained in:
parent
4bb9f96133
commit
b0150caee6
9 changed files with 97 additions and 147 deletions
16
config/initializers/omniauth.rb
Normal file
16
config/initializers/omniauth.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
OmniAuth.config.logger = Rails.logger
|
||||
OmniAuth.config.failure_raise_out_environments = []
|
||||
|
||||
if defined?(MEMCACHE_SERVERS)
|
||||
require "openid/store/memcache"
|
||||
|
||||
openid_store = OpenID::Store::Memcache.new(Dalli::Client.new(MEMCACHE_SERVERS, :namespace => "rails"))
|
||||
else
|
||||
require "openid/store/filesystem"
|
||||
|
||||
openid_store = OpenID::Store::Filesystem.new(Rails.root.join("tmp/openids"))
|
||||
end
|
||||
|
||||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
provider :openid, :name => "openid", :store => openid_store
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
if defined?(MEMCACHE_SERVERS)
|
||||
require "openid/store/memcache"
|
||||
|
||||
OpenIdAuthentication.store = OpenID::Store::Memcache.new(Dalli::Client.new(MEMCACHE_SERVERS, :namespace => "rails"))
|
||||
else
|
||||
OpenIdAuthentication.store = :file
|
||||
end
|
|
@ -1689,8 +1689,6 @@ en:
|
|||
account not active: "Sorry, your account is not active yet.<br />Please use the link in the account confirmation email to activate your account, or <a href=\"%{reconfirm}\">request a new confirmation email</a>."
|
||||
account is suspended: Sorry, your account has been suspended due to suspicious activity.<br />Please contact the <a href="%{webmaster}">webmaster</a> if you wish to discuss this.
|
||||
auth failure: "Sorry, could not log in with those details."
|
||||
openid missing provider: "Sorry, could not contact your OpenID provider"
|
||||
openid invalid: "Sorry, your OpenID seems to be malformed"
|
||||
openid_logo_alt: "Log in with an OpenID"
|
||||
openid_providers:
|
||||
openid:
|
||||
|
@ -1965,6 +1963,9 @@ en:
|
|||
This decision will be reviewed by an administrator shortly, or
|
||||
you may contact the %{webmaster} if you wish to discuss this.
|
||||
</p>
|
||||
auth_failure:
|
||||
connection_failed: Connection to authentication provider failed
|
||||
invalid_credentials: Invalid authentication credentials
|
||||
user_role:
|
||||
filter:
|
||||
not_an_administrator: "Only administrators can perform user role management, and you are not an administrator."
|
||||
|
|
|
@ -175,6 +175,11 @@ OpenStreetMap::Application.routes.draw do
|
|||
get "/create-account.html", :to => redirect(:path => "/user/new")
|
||||
get "/forgot-password.html", :to => redirect(:path => "/user/forgot-password")
|
||||
|
||||
# omniauth
|
||||
match "/auth/failure" => "user#auth_failure", :via => :get
|
||||
match "/auth/:provider/callback" => "user#auth_success", :via => [:get, :post], :as => :auth_success
|
||||
match "/auth/:provider" => "user#auth", :via => [:get, :post], :as => :auth
|
||||
|
||||
# permalink
|
||||
match "/go/:code" => "site#permalink", :via => :get, :code => /[a-zA-Z0-9_@~]+[=-]*/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue