policy_decision_point 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 (117) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/main.yml +16 -0
  3. data/.gitignore +65 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +22 -0
  6. data/.ruby-version +1 -0
  7. data/Gemfile +14 -0
  8. data/README.md +1 -0
  9. data/Rakefile +12 -0
  10. data/bin/console +15 -0
  11. data/bin/htmldiff +29 -0
  12. data/bin/ldiff +29 -0
  13. data/bin/rake +27 -0
  14. data/bin/rspec +27 -0
  15. data/bin/rubocop +27 -0
  16. data/bin/ruby-parse +27 -0
  17. data/bin/ruby-rewrite +27 -0
  18. data/bin/setup +11 -0
  19. data/example/Gemfile +65 -0
  20. data/example/Gemfile.lock +273 -0
  21. data/example/README.md +1 -0
  22. data/example/Rakefile +6 -0
  23. data/example/app/assets/config/manifest.js +2 -0
  24. data/example/app/assets/images/.keep +0 -0
  25. data/example/app/assets/stylesheets/application.css +15 -0
  26. data/example/app/channels/application_cable/channel.rb +4 -0
  27. data/example/app/channels/application_cable/connection.rb +4 -0
  28. data/example/app/controllers/application_controller.rb +2 -0
  29. data/example/app/controllers/concerns/.keep +0 -0
  30. data/example/app/controllers/rpc/hello_world/service.proto +15 -0
  31. data/example/app/controllers/rpc/hello_world/service_pb.rb +22 -0
  32. data/example/app/controllers/rpc/hello_world/service_twirp.rb +17 -0
  33. data/example/app/controllers/rpc/hello_world_server.rb +15 -0
  34. data/example/app/helpers/application_helper.rb +2 -0
  35. data/example/app/javascript/channels/consumer.js +6 -0
  36. data/example/app/javascript/channels/index.js +5 -0
  37. data/example/app/javascript/packs/application.js +13 -0
  38. data/example/app/jobs/application_job.rb +7 -0
  39. data/example/app/mailers/application_mailer.rb +4 -0
  40. data/example/app/models/application_record.rb +3 -0
  41. data/example/app/models/concerns/.keep +0 -0
  42. data/example/app/views/layouts/application.html.erb +16 -0
  43. data/example/app/views/layouts/mailer.html.erb +13 -0
  44. data/example/app/views/layouts/mailer.text.erb +1 -0
  45. data/example/babel.config.js +70 -0
  46. data/example/bin/bundle +114 -0
  47. data/example/bin/rails +27 -0
  48. data/example/bin/rake +5 -0
  49. data/example/bin/setup +36 -0
  50. data/example/bin/spring +14 -0
  51. data/example/bin/webpack +18 -0
  52. data/example/bin/webpack-dev-server +18 -0
  53. data/example/bin/yarn +17 -0
  54. data/example/config.ru +6 -0
  55. data/example/config/application.rb +25 -0
  56. data/example/config/boot.rb +4 -0
  57. data/example/config/cable.yml +10 -0
  58. data/example/config/credentials.yml.enc +1 -0
  59. data/example/config/database.yml +25 -0
  60. data/example/config/environment.rb +5 -0
  61. data/example/config/environments/development.rb +79 -0
  62. data/example/config/environments/production.rb +120 -0
  63. data/example/config/environments/test.rb +60 -0
  64. data/example/config/initializers/application_controller_renderer.rb +8 -0
  65. data/example/config/initializers/assets.rb +14 -0
  66. data/example/config/initializers/backtrace_silencers.rb +8 -0
  67. data/example/config/initializers/content_security_policy.rb +30 -0
  68. data/example/config/initializers/cookies_serializer.rb +5 -0
  69. data/example/config/initializers/filter_parameter_logging.rb +6 -0
  70. data/example/config/initializers/inflections.rb +16 -0
  71. data/example/config/initializers/mime_types.rb +4 -0
  72. data/example/config/initializers/permissions_policy.rb +11 -0
  73. data/example/config/initializers/twirp_rails.rb +4 -0
  74. data/example/config/initializers/wrap_parameters.rb +14 -0
  75. data/example/config/locales/en.yml +33 -0
  76. data/example/config/master.key +1 -0
  77. data/example/config/puma.rb +43 -0
  78. data/example/config/routes.rb +4 -0
  79. data/example/config/spring.rb +6 -0
  80. data/example/config/storage.yml +34 -0
  81. data/example/config/webpack/development.js +5 -0
  82. data/example/config/webpack/environment.js +3 -0
  83. data/example/config/webpack/production.js +5 -0
  84. data/example/config/webpack/test.js +5 -0
  85. data/example/config/webpacker.yml +92 -0
  86. data/example/extensions/x86_64-linux/3.0.0/ffi-1.15.3/ffi_c.so +0 -0
  87. data/example/extensions/x86_64-linux/3.0.0/ffi-1.15.3/gem.build_complete +0 -0
  88. data/example/extensions/x86_64-linux/3.0.0/ffi-1.15.3/gem_make.out +165 -0
  89. data/example/extensions/x86_64-linux/3.0.0/ffi-1.15.3/mkmf.log +132 -0
  90. data/example/package.json +17 -0
  91. data/example/postcss.config.js +12 -0
  92. data/example/public/404.html +67 -0
  93. data/example/public/422.html +67 -0
  94. data/example/public/500.html +66 -0
  95. data/example/public/apple-touch-icon-precomposed.png +0 -0
  96. data/example/public/apple-touch-icon.png +0 -0
  97. data/example/public/favicon.ico +0 -0
  98. data/example/public/robots.txt +1 -0
  99. data/example/storage/.keep +0 -0
  100. data/example/test/application_system_test_case.rb +5 -0
  101. data/example/test/channels/application_cable/connection_test.rb +11 -0
  102. data/example/test/controllers/.keep +0 -0
  103. data/example/test/fixtures/files/.keep +0 -0
  104. data/example/test/helpers/.keep +0 -0
  105. data/example/test/integration/.keep +0 -0
  106. data/example/test/mailers/.keep +0 -0
  107. data/example/test/models/.keep +0 -0
  108. data/example/test/system/.keep +0 -0
  109. data/example/test/test_helper.rb +13 -0
  110. data/example/tmp/cache/bootsnap/load-path-cache +0 -0
  111. data/example/vendor/.keep +0 -0
  112. data/example/yarn.lock +6888 -0
  113. data/lib/policy_decision_point.rb +24 -0
  114. data/lib/policy_decision_point/pdp.rb +155 -0
  115. data/lib/policy_decision_point/version.rb +5 -0
  116. data/policy_decision_point.gemspec +32 -0
  117. metadata +160 -0
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
File without changes
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>SampleApp</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
8
+
9
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
10
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
11
+ </head>
12
+
13
+ <body>
14
+ <%= yield %>
15
+ </body>
16
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,70 @@
1
+ module.exports = function(api) {
2
+ var validEnv = ['development', 'test', 'production']
3
+ var currentEnv = api.env()
4
+ var isDevelopmentEnv = api.env('development')
5
+ var isProductionEnv = api.env('production')
6
+ var isTestEnv = api.env('test')
7
+
8
+ if (!validEnv.includes(currentEnv)) {
9
+ throw new Error(
10
+ 'Please specify a valid `NODE_ENV` or ' +
11
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
12
+ '"test", and "production". Instead, received: ' +
13
+ JSON.stringify(currentEnv) +
14
+ '.'
15
+ )
16
+ }
17
+
18
+ return {
19
+ presets: [
20
+ isTestEnv && [
21
+ '@babel/preset-env',
22
+ {
23
+ targets: {
24
+ node: 'current'
25
+ }
26
+ }
27
+ ],
28
+ (isProductionEnv || isDevelopmentEnv) && [
29
+ '@babel/preset-env',
30
+ {
31
+ forceAllTransforms: true,
32
+ useBuiltIns: 'entry',
33
+ corejs: 3,
34
+ modules: false,
35
+ exclude: ['transform-typeof-symbol']
36
+ }
37
+ ]
38
+ ].filter(Boolean),
39
+ plugins: [
40
+ 'babel-plugin-macros',
41
+ '@babel/plugin-syntax-dynamic-import',
42
+ isTestEnv && 'babel-plugin-dynamic-import-node',
43
+ '@babel/plugin-transform-destructuring',
44
+ [
45
+ '@babel/plugin-proposal-class-properties',
46
+ {
47
+ loose: true
48
+ }
49
+ ],
50
+ [
51
+ '@babel/plugin-proposal-object-rest-spread',
52
+ {
53
+ useBuiltIns: true
54
+ }
55
+ ],
56
+ [
57
+ '@babel/plugin-transform-runtime',
58
+ {
59
+ helpers: false
60
+ }
61
+ ],
62
+ [
63
+ '@babel/plugin-transform-regenerator',
64
+ {
65
+ async: false
66
+ }
67
+ ]
68
+ ].filter(Boolean)
69
+ }
70
+ }
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
data/example/bin/rails ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by RubyGems.
4
+ #
5
+ # The application 'railties' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'rubygems'
10
+
11
+ version = ">= 0.a"
12
+
13
+ str = ARGV.first
14
+ if str
15
+ str = str.b[/\A_(.*)_\z/, 1]
16
+ if str and Gem::Version.correct?(str)
17
+ version = str
18
+ ARGV.shift
19
+ end
20
+ end
21
+
22
+ if Gem.respond_to?(:activate_bin_path)
23
+ load Gem.activate_bin_path('railties', 'rails', version)
24
+ else
25
+ gem "railties", version
26
+ load Gem.bin_path("railties", "rails", version)
27
+ end
data/example/bin/rake ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ load File.expand_path("spring", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rake"
5
+ Rake.application.run
data/example/bin/setup ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path('..', __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies
21
+ system! 'bin/yarn'
22
+
23
+ # puts "\n== Copying sample files =="
24
+ # unless File.exist?('config/database.yml')
25
+ # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
26
+ # end
27
+
28
+ puts "\n== Preparing database =="
29
+ system! 'bin/rails db:prepare'
30
+
31
+ puts "\n== Removing old logs and tempfiles =="
32
+ system! 'bin/rails log:clear tmp:clear'
33
+
34
+ puts "\n== Restarting application server =="
35
+ system! 'bin/rails restart'
36
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
3
+ gem "bundler"
4
+ require "bundler"
5
+
6
+ # Load Spring without loading other gems in the Gemfile, for speed.
7
+ Bundler.locked_gems&.specs&.find { |spec| spec.name == "spring" }&.tap do |spring|
8
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
9
+ gem "spring", spring.version
10
+ require "spring/binstub"
11
+ rescue Gem::LoadError
12
+ # Ignore when Spring is not installed.
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/webpack_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::WebpackRunner.run(ARGV)
18
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/dev_server_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::DevServerRunner.run(ARGV)
18
+ end
data/example/bin/yarn ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
+ yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
5
+ select { |dir| File.expand_path(dir) != __dir__ }.
6
+ product(["yarn", "yarn.cmd", "yarn.ps1"]).
7
+ map { |dir, file| File.expand_path(file, dir) }.
8
+ find { |file| File.executable?(file) }
9
+
10
+ if yarn
11
+ exec yarn, *ARGV
12
+ else
13
+ $stderr.puts "Yarn executable was not detected in the system."
14
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
15
+ exit 1
16
+ end
17
+ end
data/example/config.ru ADDED
@@ -0,0 +1,6 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
6
+ Rails.application.load_server
@@ -0,0 +1,25 @@
1
+ require_relative "boot"
2
+ require_relative "../policy_decision_point"
3
+
4
+ require "rails/all"
5
+
6
+ # Require the gems listed in Gemfile, including any gems
7
+ # you've limited to :test, :development, or :production.
8
+ Bundler.require(*Rails.groups)
9
+
10
+ module SampleApp
11
+ class Application < Rails::Application
12
+ # Initialize configuration defaults for originally generated Rails version.
13
+ config.load_defaults 6.1
14
+
15
+ # Configuration for the application, engines, and railties goes here.
16
+ #
17
+ # These settings can be overridden in specific environments using the files
18
+ # in config/environments, which are processed later.
19
+ #
20
+ # config.time_zone = "Central Time (US & Canada)"
21
+ # config.eager_load_paths << Rails.root.join("extras")
22
+
23
+ config.middleware.use PolicyDecisionPoint::PDP
24
+ end
25
+ end
@@ -0,0 +1,4 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
4
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: test
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: sample_app_production
@@ -0,0 +1 @@
1
+ jQNkT32qiR1jHbIjQIyuKDvxKQdrdF7mtQ49wOpH5+KmlXi6cBCRNytI7BAeA5psfBiywlqCV5vmrBkFxEowYmsUMh6rvKvySyyN1Fp8MikBP8HqFbYKPr1SK3+EUcb9MvGhSpSsswVGsNT1oJnO0iDAS2MXJMHCW9PuaQf5G6l6pRBzQnpB++44xFz/rBcS8aWBjkC8MuNGavPFTsphMqiLO3IB1QTbG5pkndECEis6Joa25EQNVyh5XPI/53aSJdPaSJzCKieIDAvIyNnT/Mv1lE8jNJXfTWng7O9O0SNqoKmqvlqGIDayggcUA0GRv5vBM5hyjfDJEHM71FEfqE/9sr2zyS8lGa755Obw5NFWQXSojYwQDdt11IS8X/m+uLBXLqczgLaNpIzjiWdxMDp+E7d56u7i3Qwl--gV01vLkm1FbIHDdd--E2nOvbRIoTcJQWtm9F7kIg==
@@ -0,0 +1,25 @@
1
+ # SQLite. Versions 3.8.0 and up are supported.
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3