Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
d4828f5
WIP: test devise github oauth integration
rsmithlal Jun 11, 2024
7cc86e2
Update omniauth routes
rsmithlal Jun 11, 2024
fb4885b
update github oauth action
rsmithlal Jun 11, 2024
68ea4bf
WIP: github oauth
rsmithlal Jun 12, 2024
72a0030
WIP: github oauth use correct user class reference
rsmithlal Jun 12, 2024
a1a9b0a
WIP: github oauth use correct user method to process auth env data
rsmithlal Jun 12, 2024
042249f
Only show oauth login links if param oauth_login=true
rsmithlal Jun 12, 2024
b7f8af6
adjustment for frozen arrays
rsmithlal Jun 12, 2024
ed709f5
WIP: initial foundation to integrate GitHub API using Octokit gem
rsmithlal Jun 12, 2024
8f2f392
rubocop fixes
rsmithlal Jun 12, 2024
163baea
WIP: Initial scaffolding of PersonPlatformIntegrations
rsmithlal Jun 12, 2024
56253fe
WIP: Flesh out PersonPlatformIntegration
rsmithlal Jun 12, 2024
d0afb15
rubocop fixes
rsmithlal Jun 12, 2024
1ec7f73
rubocop fixes
rsmithlal Jun 12, 2024
8bc4afa
WIP: attempt to correctly sign_in the user after oauth
rsmithlal Jun 16, 2024
3bdbd69
Rubocop fixes
rsmithlal Jun 16, 2024
72272b1
Merge branch 'main' into feature/github-integration
rsmithlal Jul 20, 2024
ba905b6
Merge branch 'main' into feature/github-integration
rsmithlal Mar 1, 2025
e9caf22
Update Gemfile.lock
rsmithlal Mar 1, 2025
4292d62
Improved references to ::BetterTogether modules
rsmithlal Feb 28, 2025
d2f638c
Improved success rate for generating page view urls
rsmithlal Feb 28, 2025
4ac9afb
Add BetterTogether::Metrics::PageViewReport
rsmithlal Feb 28, 2025
81bfbf2
Improve metrics reporting page with tabbed layout and add page view r…
rsmithlal Feb 28, 2025
ee4ff34
Add BetterTogether::Metrics::Pageable concern
rsmithlal Feb 28, 2025
0cf31b7
Default locale to current_person's locale if not in params and person…
rsmithlal Feb 28, 2025
93149c0
Rubocop fixes
rsmithlal Feb 28, 2025
fe025da
Address misaligned locale count and url csv headers
rsmithlal Feb 28, 2025
12a9d28
Adjust heading level of new page view report header
rsmithlal Feb 28, 2025
df59892
Update rubyonrails.yml
rsmithlal Feb 28, 2025
dfb4dd0
rubocop:disable Style/CombinableLoops for page view report csv headers
rsmithlal Feb 28, 2025
1254186
Relocate model concerns to models/concerns directory
rsmithlal Feb 28, 2025
04ea923
Rename Metrics::Pageable concern to Viewable
rsmithlal Feb 28, 2025
850edda
Add LinkClickReport and new tabbed section in link click report metri…
rsmithlal Feb 28, 2025
4af60c2
Render conversations inside of communicator view
rsmithlal Feb 28, 2025
d9a4a1a
Re-implement flexible invitation model
rsmithlal Feb 28, 2025
275fd16
Re-implement Post model
rsmithlal Feb 28, 2025
a773b3b
Re-implement Authorship system
rsmithlal Feb 28, 2025
e11d25a
Adjust page migration to use the bt_privacy helper
rsmithlal Feb 28, 2025
d12eee2
Make Community Searchable
rsmithlal Feb 28, 2025
25c4405
Rubocop fixes
rsmithlal Feb 28, 2025
adbd0ea
Allow navigation items to have fallback urls that include their ident…
rsmithlal Feb 28, 2025
d3712d5
Improve structure of importmap channels
rsmithlal Mar 1, 2025
ce61d54
Add initial feature spec for setup wizard. Coverage 28.87%
rsmithlal Mar 1, 2025
bab1aeb
Disable html content for posts for now
rsmithlal Mar 1, 2025
4872016
Set post slugged after slugged attribute is defined
rsmithlal Mar 1, 2025
5bebdd0
Rubocop fixes
rsmithlal Mar 1, 2025
09eda33
Merge branch 'dev' into feature/github-integration
rsmithlal Mar 1, 2025
ba02c2f
adjust omniauth route definitions
rsmithlal Mar 1, 2025
1598daf
Rubocop fixes
rsmithlal Mar 1, 2025
e6f76c2
Potential fix for code scanning alert no. 7: CSRF protection weakened…
rsmithlal Mar 1, 2025
2c28bd7
Rubocop fixes
rsmithlal Mar 1, 2025
96f0560
Merge branch 'dev' into feature/github-integration
rsmithlal Mar 1, 2025
71a142d
Merge branch 'dev' into feature/github-integration
rsmithlal Mar 1, 2025
6324d4e
Build(deps): Bump active_storage_validations from 1.4.0 to 2.0.2
dependabot[bot] Feb 3, 2025
4afdb1f
Build(deps): Bump redis from 5.3.0 to 5.4.0
dependabot[bot] Feb 21, 2025
b61e6b6
Build(deps): Bump aws-sdk-s3 from 1.181.0 to 1.182.0
dependabot[bot] Feb 20, 2025
df2125c
Build(deps): Bump ruby-openai from 7.3.1 to 7.4.0
dependabot[bot] Feb 20, 2025
ba84c40
Build(deps-dev): Bump rubocop from 1.72.2 to 1.73.0
dependabot[bot] Feb 27, 2025
d0ff490
Add ActsAsTenant to gemspec and Gemfile.lock
rsmithlal Mar 4, 2025
fdc0f66
Remove unlisted as an option for privacy
rsmithlal Mar 4, 2025
728680a
No longer excluding db schema and migrations from string literal rubo…
rsmithlal Mar 4, 2025
8700a1b
Improve the SetupWizard platform details page
rsmithlal Mar 4, 2025
4add9dd
Move time zone control into a stimulus controller
rsmithlal Mar 5, 2025
d063df6
Move language translation keys under better_together namespace
rsmithlal Mar 5, 2025
590b59a
Customize default theme colours
rsmithlal Mar 5, 2025
4f616f6
Allow viewing default informational and promo pages without a host pl…
rsmithlal Mar 5, 2025
20d1abc
Improve platform setup page copywriting
rsmithlal Mar 5, 2025
7170747
Add BetterTogether::Seed
rsmithlal Mar 5, 2025
ea3b6df
refactor admin_creation setup wizard step to use same style as platfo…
rsmithlal Mar 5, 2025
b7c0c68
Add custom seed data config for BetterTogether::Wizard
rsmithlal Mar 5, 2025
8ac0493
Merge branch 'dev' into feature/github-integration
rsmithlal Mar 7, 2025
eb7d6f9
Merge branch 'dev' into feature/github-integration
rsmithlal Mar 7, 2025
b7ef209
Merge branch 'main' into feature/github-integration
rsmithlal Jun 28, 2025
61181ef
Merge branch 'main' into feature/github-integration
rsmithlal Jul 5, 2025
6a7b670
Merge branch 'main' into feature/github-integration
rsmithlal Aug 7, 2025
6bdb807
Merge branch 'main' into feature/github-integration
rsmithlal Aug 24, 2025
e623c52
Rubocop fixes
rsmithlal Aug 24, 2025
0e1d92a
Rubocop fixes
rsmithlal Aug 24, 2025
10d44f0
Rubocop fixes
rsmithlal Aug 24, 2025
81bd298
Refactor destroy? method placement in PersonBlockPolicy
rsmithlal Aug 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ PATH
jsonapi-resources (>= 0.10.0)
mobility (>= 1.0.1, < 2.0)
mobility-actiontext (~> 1.1)
omniauth
omniauth-github (~> 2.0.0)
omniauth-rails_csrf_protection
pundit (>= 2.1, < 2.4)
pundit-resources
rack-cors (>= 1.1.1, < 2.1.0)
Expand Down Expand Up @@ -236,6 +239,10 @@ GEM
railties (>= 5.0.0)
faker (3.4.1)
i18n (>= 1.8.11, < 2)
faraday (2.9.1)
faraday-net_http (>= 2.0, < 3.2)
faraday-net_http (3.1.0)
net-http
ffi (1.17.0-x86_64-linux-gnu)
fog-aws (3.22.0)
fog-core (~> 2.1)
Expand Down Expand Up @@ -268,6 +275,7 @@ GEM
google-protobuf (4.27.1-x86_64-linux)
bigdecimal
rake (>= 13)
hashie (5.0.0)
http-accept (1.7.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
Expand Down Expand Up @@ -323,7 +331,11 @@ GEM
mobility (~> 1.2)
msgpack (1.7.2)
multi_json (1.15.0)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
mutex_m (0.2.0)
net-http (0.4.1)
uri
net-imap (0.4.12)
date
net-protocol
Expand All @@ -337,6 +349,26 @@ GEM
nio4r (2.7.3)
nokogiri (1.16.5-x86_64-linux)
racc (~> 1.4)
oauth2 (2.0.9)
faraday (>= 0.17.3, < 3.0)
jwt (>= 1.0, < 3.0)
multi_xml (~> 0.5)
rack (>= 1.2, < 4)
snaky_hash (~> 2.0)
version_gem (~> 1.1)
omniauth (2.1.2)
hashie (>= 3.4.6)
rack (>= 2.2.3)
rack-protection
omniauth-github (2.0.1)
omniauth (~> 2.0)
omniauth-oauth2 (~> 1.8)
omniauth-oauth2 (1.8.0)
oauth2 (>= 1.4, < 3)
omniauth (~> 2.0)
omniauth-rails_csrf_protection (1.0.2)
actionpack (>= 4.2)
omniauth (~> 2.0)
optimist (3.1.0)
orm_adapter (0.5.0)
parallel (1.24.0)
Expand Down Expand Up @@ -543,6 +575,9 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
spring (4.2.1)
spring-watcher-listen (2.1.0)
listen (>= 2.7, < 4.0)
Expand Down Expand Up @@ -581,6 +616,8 @@ GEM
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.5.0)
uri (0.13.0)
version_gem (1.1.4)
warden (1.2.9)
rack (>= 2.0.9)
warden-jwt_auth (0.8.0)
Expand Down
24 changes: 24 additions & 0 deletions app/concerns/better_together/devise_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ module DeviseUser

validates :email, presence: true, uniqueness: { case_sensitive: false }

def self.from_omniauth(auth)
find_or_create_by(provider: auth.provider, uid: auth.uid) do |user|
user.email = auth.info.email
user.password = Devise.friendly_token[0, 20]
# user.name = auth.info.name # assuming the user model has a name
# user.image = auth.info.image # assuming the user model has an image
# If you are using confirmable and the provider(s) you use validate emails,
# uncomment the line below to skip the confirmation emails.
# user.skip_confirmation!
end
end

def self.new_with_session(params, session)
super.tap do |user|
if data = session["devise.github_data"] && session["devise.github_data"]["extra"]["raw_info"]
user.email = data["email"] if user.email.blank?
end
end
end

# TODO: address the confirmation and password reset email modifications for api users when the API is under
# active development and full use.
# override devise method to include additional info as opts hash
Expand All @@ -27,6 +47,10 @@ def send_confirmation_instructions(opts = {})
send_devise_notification(:confirmation_instructions, @raw_confirmation_token, opts)
end

def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later
end

# # override devise method to include additional info as opts hash
def send_reset_password_instructions(opts = {})
token = set_reset_password_token
Expand Down
22 changes: 22 additions & 0 deletions app/controllers/better_together/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

class BetterTogether::OmniauthCallbacksController < Devise::OmniauthCallbacksController
# See https://github.com/omniauth/omniauth/wiki/FAQ#rails-session-is-clobbered-after-callback-on-developer-strategy
skip_before_action :verify_authenticity_token, only: :github

def github
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user = BetterTogether.user_class.constantize.from_omniauth(request.env["omniauth.auth"])

if @user.persisted?
sign_in_and_redirect @user, event: :authentication # this will throw if @user is not activated
set_flash_message(:notice, :success, kind: "GitHub") if is_navigational_format?
else
session["devise.github_data"] = request.env["omniauth.auth"].except(:extra) # Removing extra as it can overflow some session stores
redirect_to new_user_registration_url
end
end

def failure
redirect_to helpers.base_url
end
end
6 changes: 4 additions & 2 deletions app/models/better_together/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ class User < ApplicationRecord
include ::BetterTogether::DeviseUser
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable,
devise :database_authenticatable, :omniauthable,
:recoverable, :rememberable, :validatable, :confirmable,
:jwt_authenticatable, jwt_revocation_strategy: JwtDenylist
:jwt_authenticatable,
jwt_revocation_strategy: JwtDenylist,
omniauth_providers: %i[github]

has_one :person_identification,
lambda {
Expand Down
1 change: 1 addition & 0 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<div class="text-center">
<%= f.submit "Log in", class: 'btn btn-primary' %>
</div>
<%= link_to "Sign in with GitHub", user_github_omniauth_authorize_path, data: { turbo: false } %>
<% end %>

<!-- Additional Links -->
Expand Down
3 changes: 3 additions & 0 deletions better_together.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Gem::Specification.new do |spec|
spec.add_dependency 'jsonapi-resources', '>= 0.10.0'
spec.add_dependency 'mobility', '>= 1.0.1', '< 2.0'
spec.add_dependency 'mobility-actiontext', '~> 1.1'
spec.add_dependency 'omniauth'
spec.add_dependency 'omniauth-github', '~> 2.0.0'
spec.add_dependency 'omniauth-rails_csrf_protection'
spec.add_dependency 'pundit', '>= 2.1', '< 2.4'
spec.add_dependency 'pundit-resources'
spec.add_dependency 'rack-cors', '>= 1.1.1', '< 2.1.0'
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
config.omniauth :github, ENV.fetch('GITHUB_CLIENT_ID', nil), ENV.fetch('GITHUB_CLIENT_SECRET', nil), scope: 'user,public_repo'

# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
devise_for :users,
class_name: BetterTogether.user_class.to_s,
module: 'devise',
skip: %i[unlocks omniauth_callbacks],
skip: %i[unlocks],
path: 'users',
path_names: {
sign_in: 'sign-in',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddOmniauthToBetterTogetherUsers < ActiveRecord::Migration[7.1]
def change
add_column :better_together_users, :provider, :string
add_column :better_together_users, :uid, :string
end
end
6 changes: 4 additions & 2 deletions lib/better_together/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
require 'devise/jwt'
require 'font-awesome-sass'
require 'importmap-rails'
require 'omniauth-github'
require 'reform/rails'
require 'sprockets/railtie'
require 'stimulus-rails'
Expand All @@ -22,7 +23,8 @@ class Engine < ::Rails::Engine
engine_name 'better_together'
isolate_namespace BetterTogether

config.autoload_paths += Dir["#{config.root}/lib/better_together/**/"]
config.autoload_paths = Dir["#{config.root}/lib/better_together/**/"] +
config.autoload_paths.to_a

config.generators do |g|
g.orm :active_record, primary_key_type: :uuid
Expand Down Expand Up @@ -63,7 +65,7 @@ class Engine < ::Rails::Engine
# Add engine manifest to precompile assets in production
initializer 'better_together.assets' do |app|
# Ensure we are not modifying frozen arrays
app.config.assets.precompile += %w[better_together_manifest.js]
app.config.assets.precompile = %w[better_together_manifest.js] + app.config.assets.precompile.to_a
app.config.assets.paths = [root.join('app', 'assets', 'images'),
root.join('app', 'javascript')] + app.config.assets.paths.to_a
end
Expand Down
2 changes: 0 additions & 2 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class Application < Rails::Application
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

config.active_storage.replace_on_assign_to_many = true

config.generators do |g|
g.orm :active_record, primary_key_type: :uuid
g.fixture_replacement :factory_bot, dir: 'spec/factories'
Expand Down
5 changes: 0 additions & 5 deletions spec/dummy/config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,3 @@

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )