aaf-gumboot 1.0.0.pre.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.rubocop.yml +15 -0
- data/Gemfile +4 -0
- data/Guardfile +18 -0
- data/LICENSE +202 -0
- data/README.md +1069 -0
- data/Rakefile +8 -0
- data/aaf-gumboot.gemspec +42 -0
- data/lib/aaf-gumboot.rb +1 -0
- data/lib/gumboot.rb +5 -0
- data/lib/gumboot/shared_examples/anonymous_controller.rb +17 -0
- data/lib/gumboot/shared_examples/api_constraints.rb +29 -0
- data/lib/gumboot/shared_examples/api_controller.rb +206 -0
- data/lib/gumboot/shared_examples/api_subjects.rb +44 -0
- data/lib/gumboot/shared_examples/application_controller.rb +223 -0
- data/lib/gumboot/shared_examples/database_schema.rb +45 -0
- data/lib/gumboot/shared_examples/foreign_keys.rb +65 -0
- data/lib/gumboot/shared_examples/permissions.rb +45 -0
- data/lib/gumboot/shared_examples/roles.rb +15 -0
- data/lib/gumboot/shared_examples/subjects.rb +29 -0
- data/lib/gumboot/strap.rb +121 -0
- data/lib/gumboot/version.rb +3 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +3 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/api/api_controller.rb +78 -0
- data/spec/dummy/app/controllers/application_controller.rb +64 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/api_subject.rb +23 -0
- data/spec/dummy/app/models/api_subject_role.rb +6 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/permission.rb +7 -0
- data/spec/dummy/app/models/role.rb +11 -0
- data/spec/dummy/app/models/subject.rb +20 -0
- data/spec/dummy/app/models/subject_role.rb +6 -0
- data/spec/dummy/app/views/dynamic_errors/forbidden.html.erb +0 -0
- data/spec/dummy/app/views/dynamic_errors/unauthorized.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +18 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +32 -0
- data/spec/dummy/config/environments/production.rb +37 -0
- data/spec/dummy/config/environments/test.rb +33 -0
- data/spec/dummy/config/initializers/assets.rb +4 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/schema.rb +51 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/api_constraints.rb +16 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/api_subjects.rb +20 -0
- data/spec/factories/permissions.rb +6 -0
- data/spec/factories/roles.rb +5 -0
- data/spec/factories/subjects.rb +24 -0
- data/spec/gumboot/api_constraints_spec.rb +18 -0
- data/spec/gumboot/api_controller_spec.rb +7 -0
- data/spec/gumboot/api_subjects_spec.rb +7 -0
- data/spec/gumboot/application_controller_spec.rb +7 -0
- data/spec/gumboot/foreign_keys_spec.rb +7 -0
- data/spec/gumboot/permissions_spec.rb +7 -0
- data/spec/gumboot/roles_spec.rb +7 -0
- data/spec/gumboot/subjects_spec.rb +7 -0
- data/spec/lib/gumboot/strap_spec.rb +330 -0
- data/spec/spec_helper.rb +45 -0
- metadata +387 -0
@@ -0,0 +1,22 @@
|
|
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: 5cba397cd99a46fce16c6cf98fabb1849200895ca7c90493d4ba0824bc7a8f16738d5ee77c99e2f261236989d16dd8caf9968300cb97968461cf11320fd2e4c2
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: a4336b182d125dcd4f9a8d115924c84d55bb60dac9633b6cd530378a8644db9a0a251d1f18186c6316a55878bd256369af4ea9a381a7ac3b26a3b1fa10151de7
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
ActiveRecord::Schema.define(version: 0) do
|
2
|
+
create_table :roles do |t|
|
3
|
+
t.string :name, null: false
|
4
|
+
t.timestamps null: false
|
5
|
+
end
|
6
|
+
|
7
|
+
create_table :permissions do |t|
|
8
|
+
t.string :value, null: false
|
9
|
+
t.belongs_to :role, null: false
|
10
|
+
t.timestamps null: false
|
11
|
+
t.index [:role_id, :value], unique: true
|
12
|
+
end
|
13
|
+
|
14
|
+
create_table :api_subjects do |t|
|
15
|
+
t.string :x509_cn, null: false
|
16
|
+
t.string :contact_name, null: false
|
17
|
+
t.string :contact_mail, null: false
|
18
|
+
t.string :description, null: false
|
19
|
+
t.boolean :enabled, null: false
|
20
|
+
t.timestamps null: false
|
21
|
+
t.index [:x509_cn], unique: true
|
22
|
+
end
|
23
|
+
|
24
|
+
create_table :api_subject_roles do |t|
|
25
|
+
t.belongs_to :api_subject, null: false
|
26
|
+
t.belongs_to :role, null: false
|
27
|
+
t.timestamps null: false
|
28
|
+
end
|
29
|
+
|
30
|
+
create_table :subjects do |t|
|
31
|
+
t.string :name, null: false
|
32
|
+
t.string :mail, null: false
|
33
|
+
t.string :targeted_id, null: false
|
34
|
+
t.string :shared_token, null: false
|
35
|
+
t.boolean :enabled, null: false
|
36
|
+
t.boolean :complete, null: false
|
37
|
+
t.timestamps null: false
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table :subject_roles do |t|
|
41
|
+
t.belongs_to :subject, null: false
|
42
|
+
t.belongs_to :role, null: false
|
43
|
+
t.timestamps null: false
|
44
|
+
end
|
45
|
+
|
46
|
+
add_foreign_key 'api_subject_roles', 'api_subjects'
|
47
|
+
add_foreign_key 'api_subject_roles', 'roles'
|
48
|
+
add_foreign_key 'permissions', 'roles'
|
49
|
+
add_foreign_key 'subject_roles', 'roles'
|
50
|
+
add_foreign_key 'subject_roles', 'subjects'
|
51
|
+
end
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class APIConstraints
|
2
|
+
def initialize(version:, default: false)
|
3
|
+
@version = version
|
4
|
+
@default = default
|
5
|
+
end
|
6
|
+
|
7
|
+
def matches?(req)
|
8
|
+
@default || req.headers['Accept'].include?(version_string)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def version_string
|
14
|
+
"application/vnd.aaf.example.v#{@version}+json"
|
15
|
+
end
|
16
|
+
end
|
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,20 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :api_subject, class: API::APISubject do
|
3
|
+
x509_cn { Faker::Lorem.word }
|
4
|
+
description { Faker::Lorem.sentence }
|
5
|
+
contact_name { Faker::Name.name }
|
6
|
+
contact_mail { Faker::Internet.email }
|
7
|
+
enabled true
|
8
|
+
|
9
|
+
trait :authorized do
|
10
|
+
transient { permission '*' }
|
11
|
+
|
12
|
+
after(:create) do |api_subject, attrs|
|
13
|
+
role = create :role
|
14
|
+
permission = create :permission, value: attrs.permission, role: role
|
15
|
+
role.permissions << permission
|
16
|
+
role.api_subjects << api_subject
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :subject do
|
3
|
+
name { Faker::Name.name }
|
4
|
+
mail { Faker::Internet.email }
|
5
|
+
enabled true
|
6
|
+
complete true
|
7
|
+
|
8
|
+
shared_token { SecureRandom.urlsafe_base64(16) }
|
9
|
+
targeted_id do
|
10
|
+
"https://rapid.example.com!https://ide.example.com!#{SecureRandom.hex}"
|
11
|
+
end
|
12
|
+
|
13
|
+
trait :authorized do
|
14
|
+
transient { permission '*' }
|
15
|
+
|
16
|
+
after(:create) do |subject, attrs|
|
17
|
+
role = create :role
|
18
|
+
permission = create :permission, value: attrs.permission, role: role
|
19
|
+
role.permissions << permission
|
20
|
+
role.subjects << subject
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'gumboot/shared_examples/api_constraints'
|
4
|
+
|
5
|
+
require 'api_constraints'
|
6
|
+
|
7
|
+
RSpec.describe APIConstraints do
|
8
|
+
let(:matching_request) do
|
9
|
+
headers = { 'Accept' => 'application/vnd.aaf.example.v1+json' }
|
10
|
+
instance_double(ActionDispatch::Request, headers: headers)
|
11
|
+
end
|
12
|
+
let(:non_matching_request) do
|
13
|
+
headers = { 'Accept' => 'application/vnd.aaf.example.v2+json' }
|
14
|
+
instance_double(ActionDispatch::Request, headers: headers)
|
15
|
+
end
|
16
|
+
|
17
|
+
include_examples 'API constraints'
|
18
|
+
end
|