Skip to content

Commit

Permalink
Authentication & Audit Logging (#216)
Browse files Browse the repository at this point in the history
* Drop old & empty tables: Users & RailsAdminHistories

* Pre-draft/incomplete

* First draft; Rough edges

* Draft 2; Bug fixing

* Fix test fixtures

* Better dashboard

* Polishing views, email templates, layouts and more

* Updated Dark Theme

* Fixup tables and mobile responsive layout

* Fix section headers

* API key deleted from Sendgrid; Use environment variables

* Better date display

* Add a Private Note to Password

* Only show audit button when logged in

* User relation to passwords

* Do not install dev gems for tests

* Page titles all around

* More tests

* Disable logins switch

* Email footer fixup

* New settings manager

* config gem and cleanup email templates

* Set mailer default host

* Fix timeout variables

* Updated mailer defaults; Set mailer_sender
  • Loading branch information
pglombardo committed Sep 18, 2021
1 parent f1e8aea commit 66344a5
Show file tree
Hide file tree
Showing 83 changed files with 13,589 additions and 375 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ruby.yml
Expand Up @@ -20,6 +20,9 @@ jobs:
strategy:
matrix:
ruby-version: ['2.7', '3.0']

env:
BUNDLE_WITHOUT: 'development'

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Expand Up @@ -640,3 +640,9 @@ healthchecksdb
MigrationBackup/

# End of https://www.gitignore.io/api/osx,python,pycharm,windows,visualstudio,visualstudiocode

/config/master.key

config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml
5 changes: 4 additions & 1 deletion .rubocop.yml
Expand Up @@ -21,4 +21,7 @@ Metrics/PerceivedComplexity:
Max: 15

Metrics/AbcSize:
Max: 100
Max: 100

Metrics/BlockLength:
Max: 45
9 changes: 9 additions & 0 deletions Gemfile
Expand Up @@ -12,6 +12,11 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'

# Visual Studio Additions
gem 'rubocop'
gem 'ruby-debug-ide'
gem 'debase', '0.2.5.beta2'
end

group :test do
Expand Down Expand Up @@ -66,6 +71,8 @@ gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'json', '~> 2.0' # Legacy carry-over
gem "webpacker"
gem 'will_paginate', '~> 3.3.0'
gem 'will_paginate-bootstrap-style'

# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
Expand All @@ -77,6 +84,8 @@ gem 'foreman'
gem 'jquery-rails'
gem 'puma'
gem 'oj'
gem 'devise'
gem 'config'

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Expand Down
81 changes: 81 additions & 0 deletions Gemfile.lock
Expand Up @@ -71,6 +71,8 @@ GEM
ansi (1.5.0)
archive-zip (0.12.0)
io-like (~> 0.3.0)
ast (2.4.2)
bcrypt (3.1.16)
bindex (0.8.1)
bootsnap (1.8.1)
msgpack (~> 1.0)
Expand All @@ -97,7 +99,52 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.9)
config (3.1.0)
deep_merge (~> 1.2, >= 1.2.1)
dry-validation (~> 1.0, >= 1.0.0)
crass (1.0.6)
debase (0.2.5.beta2)
debase-ruby_core_source (>= 0.10.12)
debase-ruby_core_source (0.10.12)
deep_merge (1.2.1)
devise (4.8.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
dry-configurable (0.13.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.6)
dry-container (0.9.0)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.13, >= 0.13.0)
dry-core (0.7.1)
concurrent-ruby (~> 1.0)
dry-inflector (0.2.1)
dry-initializer (3.0.4)
dry-logic (1.2.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.5, >= 0.5)
dry-schema (1.8.0)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.13, >= 0.13.0)
dry-core (~> 0.5, >= 0.5)
dry-initializer (~> 3.0)
dry-logic (~> 1.0)
dry-types (~> 1.5)
dry-types (1.5.1)
concurrent-ruby (~> 1.0)
dry-container (~> 0.3)
dry-core (~> 0.5, >= 0.5)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 1.0, >= 1.0.2)
dry-validation (1.7.0)
concurrent-ruby (~> 1.0)
dry-container (~> 0.7, >= 0.7.1)
dry-core (~> 0.5, >= 0.5)
dry-initializer (~> 3.0)
dry-schema (~> 1.8, >= 1.8.0)
erubi (1.10.0)
execjs (2.8.1)
ffi (1.15.3)
Expand Down Expand Up @@ -144,6 +191,10 @@ GEM
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
oj (3.13.2)
orm_adapter (0.5.0)
parallel (1.20.1)
parser (3.0.2.0)
ast (~> 2.4.1)
pg (1.2.3)
pry (0.13.1)
coderay (~> 1.1)
Expand Down Expand Up @@ -194,12 +245,29 @@ GEM
method_source
rake (>= 0.13)
thor (~> 1.0)
rainbow (3.0.0)
rake (13.0.6)
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (2.1.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
rubocop (1.20.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.9.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.11.0)
parser (>= 3.0.1.1)
ruby-debug-ide (0.7.2)
rake (>= 0.8.1)
ruby-progressbar (1.11.0)
rubyzip (2.3.2)
sass-rails (6.0.0)
Expand Down Expand Up @@ -237,6 +305,9 @@ GEM
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.7.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.1.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -250,6 +321,9 @@ GEM
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
will_paginate (3.3.1)
will_paginate-bootstrap-style (0.2.4)
will_paginate (~> 3.0, >= 3.0.0)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.4.2)
Expand All @@ -263,6 +337,9 @@ DEPENDENCIES
capybara (>= 2.15, < 4.0)
chromedriver-helper
coffee-rails (~> 5.0)
config
debase (= 0.2.5.beta2)
devise
ezcrypto!
foreman
high_voltage
Expand All @@ -283,6 +360,8 @@ DEPENDENCIES
rack-throttle
rack-timeout
rails (~> 6.1.4)
rubocop
ruby-debug-ide
sass-rails (~> 6.0)
selenium-webdriver
spring
Expand All @@ -294,6 +373,8 @@ DEPENDENCIES
uglifier (>= 4.0)
web-console (>= 3.3.0)
webpacker
will_paginate (~> 3.3.0)
will_paginate-bootstrap-style

RUBY VERSION
ruby 3.0.2p107
Expand Down
1 change: 1 addition & 0 deletions Procfile
@@ -1,3 +1,4 @@
release: bundle exec rails db:migrate
web: bundle exec puma -C config/puma.rb
internalweb: bundle exec puma -C config/puma.rb -e private
console: bundle exec rails console
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -15,8 +15,8 @@ def not_found
# ::AbstractController::ActionNotFound, ApplicationRecord::RecordNotFound,
# with: lambda { |exception| render_error 404, exception }


private

def render_error(status, exception)
respond_to do |format|
format.html { render template: "errors/error_#{status}", layout: 'layouts/application', status: status }
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/dashboard_controller.rb
@@ -0,0 +1,15 @@
class DashboardController < ApplicationController
before_action :authenticate_user!

def active
@active_payloads = Password.where(user_id: current_user.id, expired: false)
.paginate(page: params[:page], per_page: 30)
.order(created_at: :desc)
end

def expired
@expired_payloads = Password.where(user_id: current_user.id, expired: true)
.paginate(page: params[:page], per_page: 30)
.order(expired_on: :desc)
end
end

0 comments on commit 66344a5

Please sign in to comment.