summaryrefslogtreecommitdiff
path: root/users/lib/warden
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2014-04-17 10:12:05 +0200
committerazul <azul@riseup.net>2014-04-17 10:12:05 +0200
commit3513ad74f950b113af1ba1e3d06bc6a55c48fde5 (patch)
treedb49ebd4428053d5c8d720275b77594a531a1ad1 /users/lib/warden
parentcb6442c344d6bdaf52c3878b2de2fcf4d85f2648 (diff)
parent3d3688647fab7049e5b531c45b85c1e46a1d528f (diff)
Merge pull request #146 from azul/refactor/engines
Refactor/engines
Diffstat (limited to 'users/lib/warden')
-rw-r--r--users/lib/warden/session_serializer.rb13
-rw-r--r--users/lib/warden/strategies/secure_remote_password.rb81
2 files changed, 0 insertions, 94 deletions
diff --git a/users/lib/warden/session_serializer.rb b/users/lib/warden/session_serializer.rb
deleted file mode 100644
index 81d7076..0000000
--- a/users/lib/warden/session_serializer.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module Warden
- # Setup Session Serialization
- class SessionSerializer
- def serialize(record)
- [record.class.name, record.id]
- end
-
- def deserialize(keys)
- klass, id = keys
- klass.constantize.find(id)
- end
- end
-end
diff --git a/users/lib/warden/strategies/secure_remote_password.rb b/users/lib/warden/strategies/secure_remote_password.rb
deleted file mode 100644
index 2c334c6..0000000
--- a/users/lib/warden/strategies/secure_remote_password.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-module Warden
- module Strategies
- class SecureRemotePassword < Warden::Strategies::Base
-
- def valid?
- handshake? || authentication?
- end
-
- def authenticate!
- if authentication?
- validate!
- else # handshake
- initialize!
- end
- end
-
- protected
-
- def handshake?
- params['A'] && params['login']
- end
-
- def authentication?
- params['client_auth'] && session[:handshake]
- end
-
- def validate!
- if client = validate
- success!(User.find_by_login(client.username))
- else
- Rails.logger.warn "Login attempt failed."
- Rails.logger.debug debug_info
- Rails.logger.debug "Received: #{params['client_auth']}"
- session.delete(:handshake)
- fail!(:base => "invalid_user_pass")
- end
- end
-
- def validate
- session[:handshake].authenticate(params['client_auth'])
- end
-
- def initialize!
- if user = User.find_by_login(id)
- client = SRP::Client.new user.username,
- :verifier => user.verifier,
- :salt => user.salt
- session[:handshake] = SRP::Session.new(client, params['A'])
- custom! json_response(session[:handshake])
- else
- fail! :base => 'invalid_user_pass'
- end
- rescue SRP::InvalidEphemeral
- fail!(:base => "invalid_ephemeral")
- end
-
- def json_response(object)
- [ 200,
- {"Content-Type" => "application/json; charset=utf-8"},
- [object.to_json]
- ]
- end
-
- def id
- params["id"] || params["login"]
- end
-
- protected
-
- def debug_info
- JSON.pretty_generate(session[:handshake].internal_state)
- end
-
- end
- end
- Warden::Strategies.add :secure_remote_password,
- Warden::Strategies::SecureRemotePassword
-
-end
-
-