url_store 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -13,21 +13,38 @@ Great for:
13
13
  - access control
14
14
  - ...
15
15
 
16
-
17
16
  Install
18
17
  =======
19
- - As gem: ` sudo gem install url_store `
20
- - As Rails plugin: ` rails plugin install git://github.com/grosser/url_store.git `
18
+
19
+ When using Rails 3, include it in your Gemfile:
20
+
21
+ gem 'url_store'
22
+
23
+ When using Rails 2 or no rails at all:
24
+
25
+ sudo gem install url_store
26
+
27
+ Or as Rails plugin:
28
+
29
+ rails plugin install git://github.com/grosser/url_store.git
21
30
 
22
31
  Usage
23
32
  =====
24
- # config (e.g environment.rb)
33
+
34
+ When on Rails, create config/initializers/url_store.rb using generator. A random secret will be generated for you:
35
+
36
+ rails generate url_store:initializer
37
+
38
+ Or configure it by hand (e.g in environment.rb):
39
+
25
40
  UrlStore.defaults = {:secret => 'adadasd2adsdasd4ads4eas4dea4dsea4sd'}
26
41
 
27
- # View:
28
- <%= link_to 'paid', :controller=>:payments, :action=>:paid, :data=>UrlStore.encode(:id=>1, :status=>'paid') %>
42
+ In Rails views:
43
+
44
+ <%= link_to 'paid', :controller =>:payments, :action=>:paid, :data=>UrlStore.encode(:id=>1, :status=>'paid') %>
45
+
46
+ In controllers:
29
47
 
30
- # Controller:
31
48
  if data = UrlStore.decode(params[:data])
32
49
  Payment.find(data[:id]).update_attribute(:status, data[:status])
33
50
  else
@@ -35,18 +52,24 @@ Usage
35
52
  end
36
53
 
37
54
  ### Defaults
55
+
38
56
  UrlStore.defaults = {:secret => 'something random'} # ALWAYS use your own secret
39
57
  UrlStore.defaults = {... , :hasher => 'MD5'} # default: 'SHA1'
40
58
  UrlStore.defaults = {... , :serializer => :yaml} # default: :marshal
41
59
 
42
60
  ### Tips
61
+
43
62
  - If you need multiple UrlStores, just use ` UrlStore.new(:secret => 'sadasd', ...) `
44
63
  - As long as you stay under 2k chars there should be no problems. [max url lengths per browser/server](http://www.boutell.com/newfaq/misc/urllength.html)
45
64
  - Data is not (yet) encrypted, users could read(but not change) the encoded data
46
65
  - Replay attacks are possible <-> add a timestamp to check the freshness of the encoded data
47
66
 
48
- Author
67
+ Authors
49
68
  =======
69
+
70
+ ### [Contributors](http://github.com/grosser/url_store/contributors)
71
+ - [Priit Haamer](http://prii.it)
72
+
50
73
  [Michael Grosser](http://grosser.it)<br/>
51
74
  michael@grosser.it<br/>
52
- Hereby placed under public domain, do what you want, just do not hold me accountable...
75
+ Hereby placed under public domain, do what you want, just do not hold anyone accountable...
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -0,0 +1,12 @@
1
+ require 'rails/generators'
2
+
3
+ class UrlStore::InitializerGenerator < Rails::Generators::Base
4
+
5
+ def self.source_root
6
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
7
+ end
8
+
9
+ def create_initializer_file
10
+ template 'initializer.erb', 'config/initializers/url_store.rb'
11
+ end
12
+ end
@@ -0,0 +1 @@
1
+ UrlStore.defaults = {:secret => '<%= ActiveSupport::SecureRandom.hex(16) %>'}
@@ -0,0 +1,6 @@
1
+ class UrlStore::Railtie < ::Rails::Railtie
2
+
3
+ generators do
4
+ require 'url_store/generators/initializer'
5
+ end
6
+ end
data/lib/url_store.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'url_store/compact_encoder'
2
2
 
3
+ require 'url_store/railtie' if defined?(::Rails) && ::Rails::VERSION::MAJOR >= 3
4
+
3
5
  class UrlStore
4
6
  VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
5
7
  SECRET = 'asdkasjlwqjdqaccxnjkasdfh2313'
data/url_store.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{url_store}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-03-28}
12
+ s.date = %q{2011-05-28}
13
13
  s.description = %q{Data securely stored in urls.}
14
14
  s.email = %q{grosser.michael@gmail.com}
15
15
  s.files = [
@@ -20,6 +20,9 @@ Gem::Specification.new do |s|
20
20
  "VERSION",
21
21
  "lib/url_store.rb",
22
22
  "lib/url_store/compact_encoder.rb",
23
+ "lib/url_store/generators/initializer.rb",
24
+ "lib/url_store/generators/templates/initializer.erb",
25
+ "lib/url_store/railtie.rb",
23
26
  "spec/spec_helper.rb",
24
27
  "spec/url_store/compact_encoder_spec.rb",
25
28
  "spec/url_store_spec.rb",
@@ -27,7 +30,7 @@ Gem::Specification.new do |s|
27
30
  ]
28
31
  s.homepage = %q{http://github.com/grosser/url_store}
29
32
  s.require_paths = ["lib"]
30
- s.rubygems_version = %q{1.4.2}
33
+ s.rubygems_version = %q{1.6.2}
31
34
  s.summary = %q{Data securely stored in urls.}
32
35
  s.test_files = [
33
36
  "spec/spec_helper.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_store
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-28 00:00:00 +02:00
18
+ date: 2011-05-28 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -35,6 +35,9 @@ files:
35
35
  - VERSION
36
36
  - lib/url_store.rb
37
37
  - lib/url_store/compact_encoder.rb
38
+ - lib/url_store/generators/initializer.rb
39
+ - lib/url_store/generators/templates/initializer.erb
40
+ - lib/url_store/railtie.rb
38
41
  - spec/spec_helper.rb
39
42
  - spec/url_store/compact_encoder_spec.rb
40
43
  - spec/url_store_spec.rb
@@ -69,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
72
  requirements: []
70
73
 
71
74
  rubyforge_project:
72
- rubygems_version: 1.4.2
75
+ rubygems_version: 1.6.2
73
76
  signing_key:
74
77
  specification_version: 3
75
78
  summary: Data securely stored in urls.