devise_custom_token 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +8 -0
- data/Rakefile +1 -0
- data/devise_custom_token.gemspec +24 -0
- data/lib/devise/devise_custom_token.rb +24 -0
- data/lib/devise_custom_token/version.rb +3 -0
- data/lib/devise_custom_token.rb +3 -0
- metadata +73 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
devise_custom_token
|
2
|
+
===================
|
3
|
+
|
4
|
+
Devise strategy for customizing the authentication token used in basic authentication header. With this strategy you can set the non-password portion of the header to an arbitrary string ("token" by default). This can be placed in any order, e.g. curl -utoken:mypassword http://someplace or curl -umypassword:token http://someplace
|
5
|
+
|
6
|
+
To use: Add to your gemfile and in your devise initializer require 'devise/devise_custom_token'
|
7
|
+
|
8
|
+
To configure the non-password string set Devise::non_token_auth_value in your devise initializer.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "devise_custom_token/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "devise_custom_token"
|
7
|
+
s.version = DeviseCustomToken::VERSION
|
8
|
+
s.authors = ["sleverbor"]
|
9
|
+
s.email = ["rob.revels@g5searchmarketing.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Customize token string in basic authentication header.}
|
12
|
+
s.description = %q{Customize token string in basic authentication header.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "devise_custom_token"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'devise'
|
2
|
+
require 'devise/strategies/token_authenticatable'
|
3
|
+
module Devise
|
4
|
+
mattr_accessor :non_token_auth_value
|
5
|
+
@@non_token_auth_value='token'
|
6
|
+
|
7
|
+
class Strategies::TokenAuthenticatable
|
8
|
+
def authenticate!
|
9
|
+
auth=valid_password? ? authentication_hash.merge({authentication_keys.first=>self.password}) : authentication_hash
|
10
|
+
resource = mapping.to.find_for_token_authentication(auth)
|
11
|
+
if validate(resource)
|
12
|
+
resource.after_token_authentication
|
13
|
+
success!(resource)
|
14
|
+
else
|
15
|
+
fail(:invalid_token)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
private
|
19
|
+
|
20
|
+
def valid_password?
|
21
|
+
password.present? && password != Devise.non_token_auth_value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise_custom_token
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- sleverbor
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-05-10 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Customize token string in basic authentication header.
|
22
|
+
email:
|
23
|
+
- rob.revels@g5searchmarketing.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- README.md
|
34
|
+
- Rakefile
|
35
|
+
- devise_custom_token.gemspec
|
36
|
+
- lib/devise/devise_custom_token.rb
|
37
|
+
- lib/devise_custom_token.rb
|
38
|
+
- lib/devise_custom_token/version.rb
|
39
|
+
homepage: ""
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
hash: 3
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: devise_custom_token
|
68
|
+
rubygems_version: 1.8.6
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Customize token string in basic authentication header.
|
72
|
+
test_files: []
|
73
|
+
|