access_token 0.1.0

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.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +8 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +169 -0
  9. data/Rakefile +9 -0
  10. data/access_token.gemspec +32 -0
  11. data/examples/rails-app/.gitignore +17 -0
  12. data/examples/rails-app/Gemfile +13 -0
  13. data/examples/rails-app/Gemfile.lock +149 -0
  14. data/examples/rails-app/README.rdoc +28 -0
  15. data/examples/rails-app/Rakefile +6 -0
  16. data/examples/rails-app/app/assets/images/.keep +0 -0
  17. data/examples/rails-app/app/assets/stylesheets/application.css +15 -0
  18. data/examples/rails-app/app/controllers/application_controller.rb +23 -0
  19. data/examples/rails-app/app/controllers/auth_controller.rb +13 -0
  20. data/examples/rails-app/app/controllers/concerns/.keep +0 -0
  21. data/examples/rails-app/app/controllers/profile_controller.rb +7 -0
  22. data/examples/rails-app/app/helpers/application_helper.rb +2 -0
  23. data/examples/rails-app/app/mailers/.keep +0 -0
  24. data/examples/rails-app/app/models/.keep +0 -0
  25. data/examples/rails-app/app/models/concerns/.keep +0 -0
  26. data/examples/rails-app/app/models/user.rb +3 -0
  27. data/examples/rails-app/app/views/layouts/application.html.erb +13 -0
  28. data/examples/rails-app/bin/bundle +3 -0
  29. data/examples/rails-app/bin/rails +4 -0
  30. data/examples/rails-app/bin/rake +4 -0
  31. data/examples/rails-app/bin/setup +29 -0
  32. data/examples/rails-app/config.ru +4 -0
  33. data/examples/rails-app/config/application.rb +26 -0
  34. data/examples/rails-app/config/boot.rb +3 -0
  35. data/examples/rails-app/config/database.yml +25 -0
  36. data/examples/rails-app/config/environment.rb +5 -0
  37. data/examples/rails-app/config/environments/development.rb +41 -0
  38. data/examples/rails-app/config/environments/production.rb +79 -0
  39. data/examples/rails-app/config/environments/test.rb +42 -0
  40. data/examples/rails-app/config/initializers/assets.rb +11 -0
  41. data/examples/rails-app/config/initializers/backtrace_silencers.rb +7 -0
  42. data/examples/rails-app/config/initializers/cookies_serializer.rb +3 -0
  43. data/examples/rails-app/config/initializers/filter_parameter_logging.rb +4 -0
  44. data/examples/rails-app/config/initializers/inflections.rb +16 -0
  45. data/examples/rails-app/config/initializers/mime_types.rb +4 -0
  46. data/examples/rails-app/config/initializers/session_store.rb +3 -0
  47. data/examples/rails-app/config/initializers/wrap_parameters.rb +14 -0
  48. data/examples/rails-app/config/locales/en.yml +23 -0
  49. data/examples/rails-app/config/routes.rb +4 -0
  50. data/examples/rails-app/config/secrets.yml +25 -0
  51. data/examples/rails-app/db/migrate/20150601000736_create_users.rb +17 -0
  52. data/examples/rails-app/db/schema.rb +25 -0
  53. data/examples/rails-app/db/seeds.rb +7 -0
  54. data/examples/rails-app/lib/assets/.keep +0 -0
  55. data/examples/rails-app/lib/tasks/.keep +0 -0
  56. data/examples/rails-app/log/.keep +0 -0
  57. data/examples/rails-app/public/404.html +67 -0
  58. data/examples/rails-app/public/422.html +67 -0
  59. data/examples/rails-app/public/500.html +66 -0
  60. data/examples/rails-app/public/favicon.ico +0 -0
  61. data/examples/rails-app/public/robots.txt +5 -0
  62. data/examples/rails-app/test/controllers/.keep +0 -0
  63. data/examples/rails-app/test/fixtures/.keep +0 -0
  64. data/examples/rails-app/test/fixtures/users.yml +9 -0
  65. data/examples/rails-app/test/helpers/.keep +0 -0
  66. data/examples/rails-app/test/integration/.keep +0 -0
  67. data/examples/rails-app/test/mailers/.keep +0 -0
  68. data/examples/rails-app/test/models/.keep +0 -0
  69. data/examples/rails-app/test/models/user_test.rb +7 -0
  70. data/examples/rails-app/test/test_helper.rb +10 -0
  71. data/examples/rails-app/vendor/assets/stylesheets/.keep +0 -0
  72. data/examples/sinatra-app/Gemfile +9 -0
  73. data/examples/sinatra-app/Gemfile.lock +76 -0
  74. data/examples/sinatra-app/config.ru +2 -0
  75. data/examples/sinatra-app/server.rb +78 -0
  76. data/lib/access_token.rb +84 -0
  77. data/lib/access_token/memcached_store.rb +25 -0
  78. data/lib/access_token/null_store.rb +19 -0
  79. data/lib/access_token/redis_store.rb +28 -0
  80. data/lib/access_token/version.rb +3 -0
  81. metadata +305 -0
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_rails-app_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do
2
+ get '/profile', to: 'profile#show'
3
+ post '/auth', to: 'auth#create'
4
+ end
@@ -0,0 +1,25 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: d24ee1472fce1da471352326e734dfcfaa0a7f5c77b4abc7293dc892f80bba09c2fedd926c10296638f40212042db792e4bedde8a2bb9f3dc50d8d51a076d220
15
+ access_token_secret: b50a65a125155b94a1d833291428b775a36b77d2ebc8348b6bb5a042e959f6e3228206df9432b5ad5d6882332295730af2e2c4f18166556c444cfe149b83507c
16
+
17
+ test:
18
+ secret_key_base: cbce00000e9ea382507ad98909d7318cc75202f24dc0f55ffda7516b70b4813865483e9ba5886046ae1b53e694f570dcbde33ee3cf407eff3e8d74871d9e114c
19
+ access_token_secret: f0781c58501041177de0f5c42d9f5d5461eff09befe59ff8acc14359efc5fef45911135b033e78d6f63677629f927595fc4ea483282bf062171de7b79c34ad17
20
+
21
+ # Do not keep production secrets in the repository,
22
+ # instead read values from the environment.
23
+ production:
24
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
25
+ access_token_secret: <%= ENV["ACCESS_TOKEN_SECRET"] %>
@@ -0,0 +1,17 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ class User < ActiveRecord::Base
3
+ has_secure_password
4
+ end
5
+
6
+ def change
7
+ create_table :users do |t|
8
+ t.string :email, null: false
9
+ t.string :password_digest, null: false
10
+
11
+ t.timestamps null: false
12
+ end
13
+
14
+ add_index :users, :email, unique: true
15
+ User.create!(email: 'john@example.com', password: 'test')
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20150601000736) do
15
+
16
+ create_table "users", force: :cascade do |t|
17
+ t.string "email", null: false
18
+ t.string "password_digest", null: false
19
+ t.datetime "created_at", null: false
20
+ t.datetime "updated_at", null: false
21
+ end
22
+
23
+ add_index "users", ["email"], name: "index_users_on_email", unique: true
24
+
25
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
File without changes
File without changes
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
File without changes
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ email: MyString
5
+ password_digest: <%= BCrypt::Password.create('secret') %>
6
+
7
+ two:
8
+ email: MyString
9
+ password_digest: <%= BCrypt::Password.create('secret') %>
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class UserTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,10 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
7
+ fixtures :all
8
+
9
+ # Add more helper methods to be used by all tests here...
10
+ end
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra', require: 'sinatra/base'
4
+ gem 'access_token', path: '../..'
5
+ gem 'activerecord', require: 'active_record'
6
+ gem 'sqlite3'
7
+ gem 'bcrypt'
8
+ gem 'pry-meta'
9
+ gem 'redis'
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ access_token (0.1.0)
5
+ parsel
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (4.2.1)
11
+ activesupport (= 4.2.1)
12
+ builder (~> 3.1)
13
+ activerecord (4.2.1)
14
+ activemodel (= 4.2.1)
15
+ activesupport (= 4.2.1)
16
+ arel (~> 6.0)
17
+ activesupport (4.2.1)
18
+ i18n (~> 0.7)
19
+ json (~> 1.7, >= 1.7.7)
20
+ minitest (~> 5.1)
21
+ thread_safe (~> 0.3, >= 0.3.4)
22
+ tzinfo (~> 1.1)
23
+ arel (6.0.0)
24
+ awesome_print (1.6.1)
25
+ bcrypt (3.1.10)
26
+ builder (3.2.2)
27
+ byebug (4.0.5)
28
+ columnize (= 0.9.0)
29
+ coderay (1.1.0)
30
+ columnize (0.9.0)
31
+ i18n (0.7.0)
32
+ json (1.8.2)
33
+ method_source (0.8.2)
34
+ minitest (5.7.0)
35
+ parsel (0.2.0)
36
+ pry (0.10.1)
37
+ coderay (~> 1.1.0)
38
+ method_source (~> 0.8.1)
39
+ slop (~> 3.4)
40
+ pry-byebug (3.1.0)
41
+ byebug (~> 4.0)
42
+ pry (~> 0.10)
43
+ pry-meta (0.0.10)
44
+ awesome_print
45
+ pry
46
+ pry-byebug
47
+ pry-remote
48
+ pry-remote (0.1.8)
49
+ pry (~> 0.9)
50
+ slop (~> 3.0)
51
+ rack (1.6.1)
52
+ rack-protection (1.5.3)
53
+ rack
54
+ redis (3.2.1)
55
+ sinatra (1.4.6)
56
+ rack (~> 1.4)
57
+ rack-protection (~> 1.4)
58
+ tilt (>= 1.3, < 3)
59
+ slop (3.6.0)
60
+ sqlite3 (1.3.10)
61
+ thread_safe (0.3.5)
62
+ tilt (2.0.1)
63
+ tzinfo (1.2.2)
64
+ thread_safe (~> 0.1)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ access_token!
71
+ activerecord
72
+ bcrypt
73
+ pry-meta
74
+ redis
75
+ sinatra
76
+ sqlite3