staging_protection 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52ab40a40e2c8d892a8c4487011f8292a97a381b
4
- data.tar.gz: 6f7fa872b6580040efa79012a512e6fd43f41135
3
+ metadata.gz: 6b2b21e1141f7f1e6c3926d2b67324f515eadb1c
4
+ data.tar.gz: 03a795ae226adfdacbff1425b535f833efb5ded0
5
5
  SHA512:
6
- metadata.gz: f4b2e01e5bd6a136dab00629129d5fe0a2025d8e3f9ce1b3574b2e479e913a333a39ad96666e645d3a5972ce2f8e62d9c42668a2cc94890dcea4829efd806523
7
- data.tar.gz: 31b6d6987b8b27bf32065ffc68a3a8eef23061aaf058668202d1c08de48337f9249d15c5d9d6ab95c43c5fd7850ef4c8316f7648fb0a8dbbc2dcc9a9b2be8fd1
6
+ metadata.gz: 79362b70389288a4c190bf5d49b0902ef7bbb57bc848369791eb4427ff786be6c782a7b8fc3881556a4430913eb9508ad1af6019f61fcb3ba552c31a114d61df
7
+ data.tar.gz: ea08827fdb83e42e78cf4a99272290f7678ca9f476630d68e0ff85b1b78c977442c72aed9921d8f1dd903598577b308d893f097d12a23dad7ebd3b089710f31d
data/README.md CHANGED
@@ -27,7 +27,7 @@ Or create config file manualy.
27
27
  Set up your credentials in config file.
28
28
  Don't forget to restart web server. And that's it. Open `http://localhost:3000` (or your site url) and you'll see it is forbidden.
29
29
 
30
- Once use `http://localhost:3000/?password=<your password from config>`. Now you can walk trough your site without any password. Token is stored in cookies.
30
+ Once use `http://localhost:3000/?pass=<your password from config>`. Now you can walk trough your site without any password. Token is stored in cookies.
31
31
 
32
32
  ### Customizing access
33
33
 
@@ -41,7 +41,7 @@ module StagingProtection
41
41
 
42
42
  module InstanceMethods
43
43
  def check_password_if_required
44
- if Rails.env == environment && (request.format && (!request.format.json? || !request.format.js?)) && params[:format] != 'json'
44
+ if Rails.env == environment.to_s && (request.format && (!request.format.json? || !request.format.js?)) && params[:format] != 'json'
45
45
  if params[:pass] == password
46
46
  cookies['secret_token'] = token
47
47
  end
@@ -1,3 +1,3 @@
1
1
  module StagingProtection
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/tasks/init.rake CHANGED
@@ -3,19 +3,24 @@ namespace :staging_protection do
3
3
  task :initialize do
4
4
  path = "config/initializers/staging_protection.rb"
5
5
  file = File.open("#{Rails.root}/#{path}","w")
6
+
7
+ chars = [*('A'..'Z'), *('a'..'z'), *(0..9)]
8
+ password = (0..15).map {chars.sample}.join
9
+ token = (0..25).map {chars.sample}.join
10
+
6
11
  text = <<-TEXT
7
12
  StagingProtection.config do |config|
8
- # Password should be changed
9
- config.password = '123456'
13
+ # Password generated for your app can be changed
14
+ config.password = '#{password}'
10
15
 
11
- # Token should be changed
12
- config.token = '1234567819287321256789'
16
+ # Also you can change token
17
+ config.token = '#{token}'
13
18
 
14
19
  # Default error message can be overriden
15
20
  # config.message = 'you are not authorized to access this page.'
16
21
 
17
22
  # Default environment is staging, but it you can use any others.
18
- # config.environment = 'development'
23
+ # config.environment = :development
19
24
  end
20
25
  TEXT
21
26
  file << text
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["gaar4ica@gmail.com"]
11
11
  spec.description = "A simple gem to protect an application from search engine cache"
12
12
  spec.summary = "Use password authentication for html-like requests"
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/gaar4ica/staging_protection.git"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rails", "~> 3.2"
23
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staging_protection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anna Kazakova (gaar4ica)
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
41
55
  description: A simple gem to protect an application from search engine cache
42
56
  email:
43
57
  - gaar4ica@gmail.com
@@ -56,7 +70,7 @@ files:
56
70
  - lib/staging_protection/version.rb
57
71
  - lib/tasks/init.rake
58
72
  - staging_protection.gemspec
59
- homepage: ''
73
+ homepage: https://github.com/gaar4ica/staging_protection.git
60
74
  licenses:
61
75
  - MIT
62
76
  metadata: {}