Skip to content

Commit

Permalink
Move consent (#22)
Browse files Browse the repository at this point in the history
* Initial extraction of Nitro::Consent

* Fix railtie

* Make actions an array instead of a hash

* Add Permission

* Add support for default view

* Unexisting view means no permission

* Add support for object conditions

* Extract Consent::Permissions

* Update Consent rspec matchers

* Add documentation

* Documentation update

* Allow multiple permission directories

This allow engines to declare their own permissions

* Add consent:permissins rails generator

* Bump version

* Remove Nitro module/namespace

* Rename gem from nitro-consent to consent

* Bump version

* Remove private repository restriction

* Add Travis badge

* Setup rubygems deployment

* Bump version

* Creates a generator for spec

* Make subjects an array instead of a hash

Adds ruby 2.5.0 to travis test

* Move methods from Rspec to consent API

* Bump to 0.4

* Bump activesupport version – clear security alert

* Bump version 0.4.2

* Prevent permissions from being loaded twice

* Bump version 0.4.3

* Fix flaky spec on symbol permissions

* Update bundler version to satisfy CI scenario

* Load permissions via load instead of require

* Introduce Consent::Reloader to reload permissions in rails

* Move consent preloading to after_initialize to avoid permissions loaded twice in production

* Rubocop compliant code

* Add basic YARD docs

* Configure travis to run rubocop on test

* Bump consent to v0.5.0

* Only deploy on ruby 2.5.0

* Always reload on prepare

Reloading only when permisions file change breaks the reference of the
subject in consent. Consider the following scenario:

1. Rails is loaded, permissions to User also are loaded
2. Any file in app changes, User model is reloaded
3. Consent has a reference to the old User definition, with a different
   object_id

* Release v0.5.1

* Bump version 0.5.2

* License as MIT

See https://tech.powerhrg.com/oss-guide/docs/publishing/publish.html

* License metadata

* Whitespace

* Release 0.6.0

* Introduce ability#consent to consent specific permission to ability

* Build Consent::Permission with keys

* Do not consent invalid permission

* Only apply default permissions on initialization

* Remove permissions mapping

* Remove unused subject#view_for

* Remove unused dependency on activesupport

* Update supported rubies

* Update documentation

* Add renovate.json

* Update README.md

* Release 1.0.0

* Update rake

* Add pry for development

* Simplify find_subjects

* Add subject reference to action

* Find view definition within action context

* Remove unused permission class

* Remove nitro directory

* Fix rspec module

* Fix rubocop violations

* Extract Consent::Rspec::ConsentAction and ConsentView matchers

* Add activerecord to consent test environment

* Turn SomeModel into an activerecord

* Add support for testing scope conditions

* Improve messages for consent action and consent view matchers

* Release v1.0.1

* Adding initial portal configs

* Fixed heroes typo

* Moved consent to packages

* Switch consent to github workflows

* Add license_finder to consent

* Run consent specs against multiple rails versions

* Add power's dependency decisions

* Ignore stuff

* Bump rake, bundler and rubocop

* rubocop-powerhome autofixes

* Add rubocop to CI

* Add consent to power-tools README

* Fix Consent's portal config

* Remove duplicated license files

* Update docs/README.md

Co-authored-by: Jill Klang <[email protected]>

Co-authored-by: Jillian Tankersley <[email protected]>
Co-authored-by: Bruno Trecenti <[email protected]>
Co-authored-by: Ben Langfeld <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Wade Winningham <[email protected]>
Co-authored-by: Dang Huynh <[email protected]>
Co-authored-by: Jill Klang <[email protected]>
  • Loading branch information
8 people authored Aug 22, 2022
1 parent bde4d45 commit e641c5a
Show file tree
Hide file tree
Showing 45 changed files with 1,359 additions and 22 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/consent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: consent

on:
push:

jobs:
ruby:
uses: ./.github/workflows/_ruby-package.yml
with:
package: ${{ github.workflow }}
ruby: '["2.7.4", "3.1.2"]'
rails: '["7.0.3.1","6.1.6.1","6.0.5.1","5.2.8.1"]'
secrets: inherit
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ AuditTracker helps you centralize data tracking configuration to be used across

Lumberaxe handles logging output formatting.

[consent](https://github.com/powerhome/power-tools/blob/main/packages/consent/docs/README.md) 💎

Consent provides permission-based authorization.

## Installation 🛠

These packages are all meant to install inside of an application and aren't intended to stand alone; currently, they are all published to [RubyGems](https://rubygems.org/) and you can use standard Bundler methods to install them.
Expand Down Expand Up @@ -63,3 +67,4 @@ These packages are maintained by [Power's](https://github.com/powerhome) Heroes
## Contributing 💙

Contributions are welcome! Feel free to [open a ticket](https://github.com/powerhome/power-tools/issues/new) or a [PR](https://github.com/powerhome/power-tools/pulls).

1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
site_name: Power Tools
site_description: Packages for application configuration.
repo_url: https://github.com/powerhome/power-tools
edit_uri: edit/main/nitro_config/docs/
nav:
- 'Home': 'README.md'
plugins:
Expand Down
21 changes: 0 additions & 21 deletions packages/audit_tracker/LICENSE.txt

This file was deleted.

18 changes: 18 additions & 0 deletions packages/consent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/.bundle/
/.yardoc
/_yardoc/
coverage
pkg
/spec/reports/
**/tmp/*
!**/tmp/.gitkeep
!tmp/.gitignore
vendor/bundle
*.log
*.sqlite
*.sqlite3
Gemfile.lock

# Ignore uploaded files in development
/storage/*
!/storage/.keep
10 changes: 10 additions & 0 deletions packages/consent/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-powerhome

AllCops:
TargetRubyVersion: 2.7

Rails:
Enabled: false
13 changes: 13 additions & 0 deletions packages/consent/.rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-08-22 19:25:27 UTC using RuboCop version 1.35.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'spec/consent_spec.rb'
10 changes: 10 additions & 0 deletions packages/consent/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

source "https://rubygems.org"

# Specify your gem's dependencies in consent.gemspec
gemspec

rails_version = ENV.fetch("RAILS_VERSION", ">= 5")

gem "rails", rails_version
14 changes: 14 additions & 0 deletions packages/consent/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env rake

# frozen_string_literal: true

require "bundler/setup"
Bundler::GemHelper.install_tasks

require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

require "rubocop/rake_task"
RuboCop::RakeTask.new(:rubocop)

task default: %i[spec rubocop]
15 changes: 15 additions & 0 deletions packages/consent/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'consent'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require 'irb'
IRB.start
8 changes: 8 additions & 0 deletions packages/consent/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
32 changes: 32 additions & 0 deletions packages/consent/consent.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "consent/version"

Gem::Specification.new do |spec|
spec.name = "consent"
spec.version = Consent::VERSION
spec.authors = ["Carlos Palhares"]
spec.email = ["[email protected]"]

spec.summary = "Consent permission based authorization"
spec.description = "Consent permission based authorization"
spec.homepage = "https://github.com/powerhome/power-tools"
spec.license = "MIT"
spec.required_ruby_version = ">= 2.7"

spec.files = `git ls-files`.split.grep_v(/^(test|spec|features)/)
spec.require_paths = ["lib"]

spec.add_development_dependency "activerecord", ">= 5"
spec.add_development_dependency "bundler", "~> 2.1"
spec.add_development_dependency "cancancan", "~> 1.15.0"
spec.add_development_dependency "license_finder", ">= 7.0"
spec.add_development_dependency "pry-byebug", "3.9.0"
spec.add_development_dependency "rake", "~> 13"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop-powerhome", "0.5.0"
spec.add_development_dependency "sqlite3", "~> 1.4.2"
spec.metadata["rubygems_mfa_required"] = "true"
end
3 changes: 3 additions & 0 deletions packages/consent/doc/dependency_decisions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- - :inherit_from
- https://raw.githubusercontent.com/powerhome/oss-guide/master/license_rules.yml
Loading

0 comments on commit e641c5a

Please sign in to comment.