Compare commits
25 Commits
fb3b9af3e5
...
v0.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f08bb56a7a
|
||
| c1f275463e | |||
| 324809f77e | |||
|
|
f9b07bcb01
|
||
|
|
986eb5387c
|
||
| f76e2c2f14 | |||
|
|
22a7bbe6eb
|
||
| 18f4deb30f | |||
|
|
9f9bf6fd80
|
||
|
|
d2987da70a
|
||
|
|
6b7a80e23a
|
||
|
|
42b9b27561
|
||
|
|
c17c980b69
|
||
|
|
f199d5d12a
|
||
|
|
4b17afa93d
|
||
|
|
6d52af53ae
|
||
|
|
4c5ad67652
|
||
|
|
3437a756eb
|
||
| 0d9fc4aa74 | |||
| 82475161a9 | |||
| e1e7d8f87d | |||
|
|
5b46f3adf5
|
||
|
|
a8a8fba14c
|
||
|
|
8a7016a30b
|
||
|
|
e2618de7c6
|
@@ -7,6 +7,8 @@ SMTP_DOMAIN=example.com
|
|||||||
SMTP_AUTH_METHOD=plain
|
SMTP_AUTH_METHOD=plain
|
||||||
SMTP_ENABLE_STARTTLS=auto
|
SMTP_ENABLE_STARTTLS=auto
|
||||||
|
|
||||||
|
REDIS_URL='redis://localhost:6379/1'
|
||||||
|
|
||||||
LDAP_HOST=localhost
|
LDAP_HOST=localhost
|
||||||
LDAP_PORT=389
|
LDAP_PORT=389
|
||||||
LDAP_ADMIN_PASSWORD=passthebutter
|
LDAP_ADMIN_PASSWORD=passthebutter
|
||||||
|
|||||||
13
.gitea/release-drafter.yml
Normal file
13
.gitea/release-drafter.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name-template: 'v$RESOLVED_VERSION'
|
||||||
|
tag-template: 'v$RESOLVED_VERSION'
|
||||||
|
version-resolver:
|
||||||
|
major:
|
||||||
|
labels:
|
||||||
|
- 'release/major'
|
||||||
|
minor:
|
||||||
|
labels:
|
||||||
|
- 'release/minor'
|
||||||
|
patch:
|
||||||
|
labels:
|
||||||
|
- 'release/patch'
|
||||||
|
default: patch
|
||||||
11
.gitea/workflows/release_drafter.yml
Normal file
11
.gitea/workflows/release_drafter.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
name: Release Drafter
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [closed]
|
||||||
|
jobs:
|
||||||
|
release_drafter_job:
|
||||||
|
name: Update release notes draft
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Release Drafter
|
||||||
|
uses: https://github.com/raucao/gitea-release-drafter@dev
|
||||||
15
Dockerfile
15
Dockerfile
@@ -1,8 +1,13 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
FROM ruby:2.7.6
|
FROM ruby:2.7.6
|
||||||
RUN apt-get update -qq && apt-get install -y curl ldap-utils
|
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
|
RUN apt-get update -qq && apt-get install -y --no-install-recommends curl \
|
||||||
|
ldap-utils tini
|
||||||
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
|
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
|
||||||
RUN apt-get update && apt-get install -y nodejs
|
RUN apt-get update && apt-get install -y nodejs
|
||||||
|
|
||||||
WORKDIR /akkounts
|
WORKDIR /akkounts
|
||||||
COPY Gemfile /akkounts/Gemfile
|
COPY Gemfile /akkounts/Gemfile
|
||||||
COPY Gemfile.lock /akkounts/Gemfile.lock
|
COPY Gemfile.lock /akkounts/Gemfile.lock
|
||||||
@@ -12,11 +17,5 @@ RUN gem install foreman
|
|||||||
RUN npm install -g yarn
|
RUN npm install -g yarn
|
||||||
RUN yarn install
|
RUN yarn install
|
||||||
|
|
||||||
# Add a script to be executed every time the container starts.
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||||
COPY docker/entrypoint.sh /usr/bin/
|
|
||||||
RUN chmod +x /usr/bin/entrypoint.sh
|
|
||||||
ENTRYPOINT ["entrypoint.sh"]
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Configure the main process to run when running the image
|
|
||||||
CMD ["bin", "dev"]
|
|
||||||
|
|||||||
4
Gemfile
4
Gemfile
@@ -48,6 +48,10 @@ gem 'faraday'
|
|||||||
gem 'sidekiq', '< 7'
|
gem 'sidekiq', '< 7'
|
||||||
gem 'sidekiq-scheduler'
|
gem 'sidekiq-scheduler'
|
||||||
|
|
||||||
|
# Monitoring
|
||||||
|
gem "sentry-ruby"
|
||||||
|
gem "sentry-rails"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Use sqlite3 as the database for Active Record
|
# Use sqlite3 as the database for Active Record
|
||||||
gem 'sqlite3', '~> 1.4'
|
gem 'sqlite3', '~> 1.4'
|
||||||
|
|||||||
@@ -254,6 +254,11 @@ GEM
|
|||||||
ruby2_keywords (0.0.5)
|
ruby2_keywords (0.0.5)
|
||||||
rufus-scheduler (3.8.2)
|
rufus-scheduler (3.8.2)
|
||||||
fugit (~> 1.1, >= 1.1.6)
|
fugit (~> 1.1, >= 1.1.6)
|
||||||
|
sentry-rails (5.8.0)
|
||||||
|
railties (>= 5.0)
|
||||||
|
sentry-ruby (~> 5.8.0)
|
||||||
|
sentry-ruby (5.8.0)
|
||||||
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
sidekiq (6.5.5)
|
sidekiq (6.5.5)
|
||||||
connection_pool (>= 2.2.2)
|
connection_pool (>= 2.2.2)
|
||||||
rack (~> 2.0)
|
rack (~> 2.0)
|
||||||
@@ -335,6 +340,8 @@ DEPENDENCIES
|
|||||||
rails-settings-cached (~> 2.8.3)
|
rails-settings-cached (~> 2.8.3)
|
||||||
rqrcode (~> 2.0)
|
rqrcode (~> 2.0)
|
||||||
rspec-rails
|
rspec-rails
|
||||||
|
sentry-rails
|
||||||
|
sentry-ruby
|
||||||
sidekiq (< 7)
|
sidekiq (< 7)
|
||||||
sidekiq-scheduler
|
sidekiq-scheduler
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ so:
|
|||||||
|
|
||||||
1. Make sure [Docker Compose is installed][1] and Docker is running (included in
|
1. Make sure [Docker Compose is installed][1] and Docker is running (included in
|
||||||
Docker Desktop)
|
Docker Desktop)
|
||||||
2. Uncomment the `web` section in `docker-compose.yml`
|
2. Uncomment the `redis`, `web`, and `sidekiq` sections in `docker-compose.yml`
|
||||||
3. Run `docker compose up` and wait until 389ds announces its successful start
|
3. Run `docker compose up` and wait until 389ds announces its successful start
|
||||||
in the log output
|
in the log output
|
||||||
4. `docker-compose exec ldap dsconf localhost backend create --suffix="dc=kosmos,dc=org" --be-name="dev"`
|
4. `docker-compose exec ldap dsconf localhost backend create --suffix="dc=kosmos,dc=org" --be-name="dev"`
|
||||||
|
|||||||
@@ -5,10 +5,4 @@
|
|||||||
&:visited { @apply text-indigo-600; }
|
&:visited { @apply text-indigo-600; }
|
||||||
&:active { @apply text-red-600; }
|
&:active { @apply text-red-600; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.devise-links {
|
|
||||||
a {
|
|
||||||
@apply ks-text-link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<%= button_tag type: "button", name: "toggle", data: @data,
|
<%= button_tag type: "button", name: "toggle", data: @data,
|
||||||
role: "switch", aria: { checked: @enabled.to_s },
|
role: "switch", aria: { checked: @enabled.to_s },
|
||||||
disabled: !@input_enabled,
|
tabindex: @tabindex, disabled: !@input_enabled,
|
||||||
class: "#{ @enabled ? 'bg-blue-600' : 'bg-gray-200' }
|
class: "#{ @enabled ? 'bg-blue-600' : 'bg-gray-200' }
|
||||||
#{ @class_names.present? ? @class_names : '' }
|
#{ @class_names.present? ? @class_names : '' }
|
||||||
relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer
|
relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
module FormElements
|
module FormElements
|
||||||
class ToggleComponent < ViewComponent::Base
|
class ToggleComponent < ViewComponent::Base
|
||||||
def initialize(enabled:, input_enabled: true, data: nil, class_names: nil)
|
def initialize(enabled:, input_enabled: true, data: nil, class_names: nil, tabindex: nil)
|
||||||
@enabled = !!enabled
|
@enabled = !!enabled
|
||||||
@input_enabled = input_enabled
|
@input_enabled = input_enabled
|
||||||
@data = data
|
@data = data
|
||||||
@class_names = class_names
|
@class_names = class_names
|
||||||
|
@tabindex = tabindex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,18 @@ class ApplicationController < ActionController::Base
|
|||||||
render :text => exception, :status => 500
|
render :text => exception, :status => 500
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before_action :sentry_set_user
|
||||||
|
|
||||||
|
def sentry_set_user
|
||||||
|
return unless Setting.sentry_enabled
|
||||||
|
|
||||||
|
if user_signed_in?
|
||||||
|
Sentry.set_user(id: current_user.id, username: current_user.cn)
|
||||||
|
else
|
||||||
|
Sentry.set_user({})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def require_user_signed_in
|
def require_user_signed_in
|
||||||
unless user_signed_in?
|
unless user_signed_in?
|
||||||
redirect_to welcome_path and return
|
redirect_to welcome_path and return
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ export default class extends Controller {
|
|||||||
static targets = ["buttons", "countdown"]
|
static targets = ["buttons", "countdown"]
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
|
// Devise timeoutable ends up adding a second flash message without content
|
||||||
|
// TODO investigate bug
|
||||||
|
if (this.element.textContent.trim() == "true") return;
|
||||||
|
|
||||||
const timeoutSeconds = parseInt(this.data.get("timeout"));
|
const timeoutSeconds = parseInt(this.data.get("timeout"));
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# Send email via Sidekiq:
|
# Send email via Sidekiq:
|
||||||
#
|
#
|
||||||
# CustomMailer.with(user: u, subject: "Important announcement", body: body).custom_message.deliver_later
|
# CustomMailer.with(user: user, subject: "Important announcement", body: body).custom_message.deliver_later
|
||||||
#
|
#
|
||||||
class CustomMailer < ApplicationMailer
|
class CustomMailer < ApplicationMailer
|
||||||
def custom_message
|
def custom_message
|
||||||
|
|||||||
@@ -2,6 +2,13 @@
|
|||||||
class Setting < RailsSettings::Base
|
class Setting < RailsSettings::Base
|
||||||
cache_prefix { "v1" }
|
cache_prefix { "v1" }
|
||||||
|
|
||||||
|
#
|
||||||
|
# Internal services
|
||||||
|
#
|
||||||
|
|
||||||
|
field :redis_url, type: :string, readonly: true,
|
||||||
|
default: ENV["REDIS_URL"] || "redis://localhost:6379/0"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Registrations
|
# Registrations
|
||||||
#
|
#
|
||||||
@@ -10,6 +17,13 @@ class Setting < RailsSettings::Base
|
|||||||
account accounts donations mail webmaster support
|
account accounts donations mail webmaster support
|
||||||
]
|
]
|
||||||
|
|
||||||
|
#
|
||||||
|
# Sentry
|
||||||
|
#
|
||||||
|
|
||||||
|
field :sentry_enabled, type: :boolean, readonly: true,
|
||||||
|
default: (ENV["SENTRY_DSN"].present?.to_s || false)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Discourse
|
# Discourse
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ class User < ApplicationRecord
|
|||||||
devise :ldap_authenticatable,
|
devise :ldap_authenticatable,
|
||||||
:confirmable,
|
:confirmable,
|
||||||
:recoverable,
|
:recoverable,
|
||||||
:validatable
|
:validatable,
|
||||||
|
:timeoutable,
|
||||||
|
:rememberable
|
||||||
|
|
||||||
def ldap_before_save
|
def ldap_before_save
|
||||||
self.email = Devise::LDAP::Adapter.get_ldap_param(self.cn, "mail").first
|
self.email = Devise::LDAP::Adapter.get_ldap_param(self.cn, "mail").first
|
||||||
@@ -53,7 +55,18 @@ class User < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def devise_after_confirmation
|
def devise_after_confirmation
|
||||||
enable_service %w[discourse gitea mediawiki ejabberd]
|
enable_service %w[ discourse ejabberd gitea mediawiki ]
|
||||||
|
|
||||||
|
#TODO enable in development when we have easy setup of ejabberd etc.
|
||||||
|
return if Rails.env.development?
|
||||||
|
|
||||||
|
if inviter.present?
|
||||||
|
exchange_xmpp_contact_with_inviter if Setting.ejabberd_enabled?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_devise_notification(notification, *args)
|
||||||
|
devise_mailer.send(notification, self, *args).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_password(new_password, new_password_confirmation)
|
def reset_password(new_password, new_password_confirmation)
|
||||||
@@ -120,6 +133,12 @@ class User < ApplicationRecord
|
|||||||
ldap.delete_attribute(dn,:service)
|
ldap.delete_attribute(dn,:service)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def exchange_xmpp_contact_with_inviter
|
||||||
|
return unless inviter.services_enabled.include?("ejabberd") &&
|
||||||
|
services_enabled.include?("ejabberd")
|
||||||
|
XmppExchangeContactsJob.perform_later(inviter, self.cn, self.ou)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def ldap
|
def ldap
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ class CreateAccount < ApplicationService
|
|||||||
def call
|
def call
|
||||||
user = create_user_in_database
|
user = create_user_in_database
|
||||||
add_ldap_document
|
add_ldap_document
|
||||||
create_lndhub_account(user)
|
create_lndhub_account(user) if Setting.lndhub_enabled
|
||||||
|
|
||||||
if @invitation.present?
|
if @invitation.present?
|
||||||
update_invitation(user.id)
|
update_invitation(user.id)
|
||||||
exchange_xmpp_contacts if Setting.ejabberd_enabled
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -43,12 +42,6 @@ class CreateAccount < ApplicationService
|
|||||||
CreateLdapUserJob.perform_later(@username, @domain, @email, hashed_pw)
|
CreateLdapUserJob.perform_later(@username, @domain, @email, hashed_pw)
|
||||||
end
|
end
|
||||||
|
|
||||||
def exchange_xmpp_contacts
|
|
||||||
#TODO enable in development when we have easy setup of ejabberd etc.
|
|
||||||
return if Rails.env.development?
|
|
||||||
XmppExchangeContactsJob.perform_later(@invitation.user, @username, @domain)
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_lndhub_account(user)
|
def create_lndhub_account(user)
|
||||||
#TODO enable in development when we have a local lndhub (mock?) API
|
#TODO enable in development when we have a local lndhub (mock?) API
|
||||||
return if Rails.env.development?
|
return if Rails.env.development?
|
||||||
|
|||||||
@@ -7,19 +7,43 @@
|
|||||||
<%= f.label :cn, 'User', class: 'block mb-2 font-bold' %>
|
<%= f.label :cn, 'User', class: 'block mb-2 font-bold' %>
|
||||||
<p class="flex gap-2 items-center">
|
<p class="flex gap-2 items-center">
|
||||||
<%= f.text_field :cn, autofocus: true, autocomplete: "username",
|
<%= f.text_field :cn, autofocus: true, autocomplete: "username",
|
||||||
required: true, class: "relative grow"%>
|
required: true, class: "relative grow", tabindex: "1" %>
|
||||||
<span class="relative shrink-0 text-gray-500">@ kosmos.org</span>
|
<span class="relative shrink-0 text-gray-500">@ kosmos.org</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p class="mb-8">
|
||||||
<%= f.label :password, class: 'block mb-2 font-bold' %>
|
<%= f.label :password, class: 'block mb-2 font-bold' %>
|
||||||
<%= f.password_field :password, autocomplete: "current-password",
|
<%= f.password_field :password, autocomplete: "current-password",
|
||||||
required: true, class: "w-full"%>
|
required: true, class: "w-full", tabindex: "2" %>
|
||||||
</p>
|
</p>
|
||||||
<p class="mt-8">
|
|
||||||
<%= f.submit "Log in", class: 'btn-md btn-blue w-full' %>
|
<%= tag.div class: "flex items-center mb-8 gap-x-3", data: {
|
||||||
|
controller: "settings--toggle",
|
||||||
|
:'settings--toggle-switch-enabled-value' => "false"
|
||||||
|
} do %>
|
||||||
|
<div class="relative inline-flex flex-shrink-0">
|
||||||
|
<%= render FormElements::ToggleComponent.new(
|
||||||
|
enabled: false, input_enabled: true, class_names: "hidden",
|
||||||
|
tabindex: "3", data: {
|
||||||
|
:'settings--toggle-target' => "button",
|
||||||
|
action: "settings--toggle#toggleSwitch"
|
||||||
|
}) %>
|
||||||
|
<%= f.check_box :remember_me, {
|
||||||
|
checked: false,
|
||||||
|
data: { :'settings--toggle-target' => "checkbox" }
|
||||||
|
}, "true", "false" %>
|
||||||
|
</div>
|
||||||
|
<%= f.label :remember_me,
|
||||||
|
class: "text-gray-500 flex flex-col",
|
||||||
|
data: { action: "click->settings--toggle#toggleSwitch" } %>
|
||||||
|
<p class="grow text-sm text-right">
|
||||||
|
<%= link_to "Forgot your password?", new_password_path(resource_name),
|
||||||
|
class: "text-gray-500 underline" %><br />
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= f.submit "Log in", class: 'btn-md btn-blue w-full', tabindex: "4" %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render "devise/shared/links" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,25 +1,29 @@
|
|||||||
<div class="devise-links mt-8 text-sm">
|
<div class="devise-links mt-8 text-sm">
|
||||||
<%- if controller_name != 'sessions' %>
|
<%- if controller_name != 'sessions' %>
|
||||||
<p class="mb-1.5">
|
<p class="mb-2">
|
||||||
<%= link_to "Log in", new_session_path(resource_name) %><br />
|
<%= link_to "Log in", new_session_path(resource_name),
|
||||||
|
class: "text-gray-500 underline" %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
||||||
<p class="mb-1.5">
|
<p class="mb-2">
|
||||||
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
<%= link_to "Forgot your password?", new_password_path(resource_name),
|
||||||
|
class: "text-gray-500 underline" %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
<%- if devise_mapping.confirmable? && !controller_name.match(/^(confirmations|sessions)$/) %>
|
||||||
<p class="mb-1.5">
|
<p class="mb-2">
|
||||||
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name),
|
||||||
|
class: "text-gray-500 underline" %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
||||||
<p class="mb-1.5">
|
<p class="mb-2">
|
||||||
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name),
|
||||||
|
class: "text-gray-500 underline" %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ require "active_record/railtie"
|
|||||||
# require "active_storage/engine"
|
# require "active_storage/engine"
|
||||||
require "action_controller/railtie"
|
require "action_controller/railtie"
|
||||||
require "action_mailer/railtie"
|
require "action_mailer/railtie"
|
||||||
# require "action_mailbox/engine"
|
require "action_mailbox/engine"
|
||||||
# require "action_text/engine"
|
# require "action_text/engine"
|
||||||
require "action_view/railtie"
|
require "action_view/railtie"
|
||||||
require "action_cable/engine"
|
require "action_cable/engine"
|
||||||
|
|||||||
@@ -186,13 +186,13 @@ Devise.setup do |config|
|
|||||||
|
|
||||||
# ==> Configuration for :rememberable
|
# ==> Configuration for :rememberable
|
||||||
# The time the user will be remembered without asking for credentials again.
|
# The time the user will be remembered without asking for credentials again.
|
||||||
# config.remember_for = 2.weeks
|
config.remember_for = 2.weeks
|
||||||
|
|
||||||
# Invalidates all the remember me tokens when the user signs out.
|
# Invalidates all the remember me tokens when the user signs out.
|
||||||
config.expire_all_remember_me_on_sign_out = true
|
config.expire_all_remember_me_on_sign_out = true
|
||||||
|
|
||||||
# If true, extends the user's remember period when remembered via cookie.
|
# If true, extends the user's remember period when remembered via cookie.
|
||||||
# config.extend_remember_period = false
|
config.extend_remember_period = true
|
||||||
|
|
||||||
# Options to be passed to the created cookie. For instance, you can set
|
# Options to be passed to the created cookie. For instance, you can set
|
||||||
# secure: true in order to force SSL only cookies.
|
# secure: true in order to force SSL only cookies.
|
||||||
@@ -210,7 +210,7 @@ Devise.setup do |config|
|
|||||||
# ==> Configuration for :timeoutable
|
# ==> Configuration for :timeoutable
|
||||||
# The time you want to timeout the user session without activity. After this
|
# The time you want to timeout the user session without activity. After this
|
||||||
# time the user will be asked for credentials again. Default is 30 minutes.
|
# time the user will be asked for credentials again. Default is 30 minutes.
|
||||||
# config.timeout_in = 30.minutes
|
config.timeout_in = 30.minutes
|
||||||
|
|
||||||
# ==> Configuration for :lockable
|
# ==> Configuration for :lockable
|
||||||
# Defines which strategy will be used to lock an account.
|
# Defines which strategy will be used to lock an account.
|
||||||
|
|||||||
9
config/initializers/sentry.rb
Normal file
9
config/initializers/sentry.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
if ENV["SENTRY_DSN"].present?
|
||||||
|
Sentry.init do |config|
|
||||||
|
config.dsn = ENV["SENTRY_DSN"]
|
||||||
|
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
|
||||||
|
config.traces_sampler = lambda do |context|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
5
config/initializers/sidekiq.rb
Normal file
5
config/initializers/sidekiq.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require_relative "../../app/models/setting"
|
||||||
|
|
||||||
|
Sidekiq.configure_server do |config|
|
||||||
|
config.redis = { url: Setting.redis_url }
|
||||||
|
end
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
require 'sidekiq/web'
|
require 'sidekiq/web'
|
||||||
|
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
devise_for :users, :controllers => { :confirmations => "users/confirmations" }
|
devise_for :users, controllers: { confirmations: "users/confirmations" }
|
||||||
|
|
||||||
get 'welcome', to: 'welcome#index'
|
get 'welcome', to: 'welcome#index'
|
||||||
get 'check_your_email', to: 'welcome#check_your_email'
|
get 'check_your_email', to: 'welcome#check_your_email'
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
:concurrency: 2
|
:concurrency: 2
|
||||||
:queues:
|
:queues:
|
||||||
- default
|
- default
|
||||||
|
- mailers
|
||||||
|
|||||||
7
config/storage.yml
Normal file
7
config/storage.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
test:
|
||||||
|
service: Disk
|
||||||
|
root: <%= Rails.root.join("tmp/storage") %>
|
||||||
|
|
||||||
|
local:
|
||||||
|
service: Disk
|
||||||
|
root: <%= Rails.root.join("storage") %>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class AddRememberCreatedAtToUsers < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :users, :remember_created_at, :datetime
|
||||||
|
add_column :users, :remember_token, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.0].define(version: 2023_02_23_115536) do
|
ActiveRecord::Schema[7.0].define(version: 2023_03_19_101128) do
|
||||||
create_table "donations", force: :cascade do |t|
|
create_table "donations", force: :cascade do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "amount_sats"
|
t.integer "amount_sats"
|
||||||
@@ -57,6 +57,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_23_115536) do
|
|||||||
t.text "ln_login_ciphertext"
|
t.text "ln_login_ciphertext"
|
||||||
t.text "ln_password_ciphertext"
|
t.text "ln_password_ciphertext"
|
||||||
t.string "ln_account"
|
t.string "ln_account"
|
||||||
|
t.datetime "remember_created_at"
|
||||||
|
t.string "remember_token"
|
||||||
t.index ["email"], name: "index_users_on_email", unique: true
|
t.index ["email"], name: "index_users_on_email", unique: true
|
||||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,11 +3,67 @@ services:
|
|||||||
image: 4teamwork/389ds:latest
|
image: 4teamwork/389ds:latest
|
||||||
volumes:
|
volumes:
|
||||||
- ./tmp/389ds:/data
|
- ./tmp/389ds:/data
|
||||||
|
networks:
|
||||||
|
- external_network
|
||||||
|
- internal_network
|
||||||
ports:
|
ports:
|
||||||
- "389:3389"
|
- "389:3389"
|
||||||
environment:
|
environment:
|
||||||
DS_DM_PASSWORD: passthebutter
|
DS_DM_PASSWORD: passthebutter
|
||||||
SUFFIX_NAME: "dc=kosmos,dc=org"
|
SUFFIX_NAME: "dc=kosmos,dc=org"
|
||||||
|
|
||||||
|
# redis:
|
||||||
|
# restart: always
|
||||||
|
# image: redis:7-alpine
|
||||||
|
# networks:
|
||||||
|
# - internal_network
|
||||||
|
# healthcheck:
|
||||||
|
# test: ['CMD', 'redis-cli', 'ping']
|
||||||
|
# volumes:
|
||||||
|
# - ./tmp/redis:/data
|
||||||
|
|
||||||
|
# web:
|
||||||
|
# build: .
|
||||||
|
# tty: true
|
||||||
|
# command: bash -c "rm -f /akkounts/tmp/pids/server.pid; bin/dev"
|
||||||
|
# volumes:
|
||||||
|
# - .:/akkounts
|
||||||
|
# networks:
|
||||||
|
# - external_network
|
||||||
|
# - internal_network
|
||||||
|
# ports:
|
||||||
|
# - "3000:3000"
|
||||||
|
# environment:
|
||||||
|
# RAILS_ENV: development
|
||||||
|
# REDIS_URL: redis://redis:6379/0
|
||||||
|
# LDAP_HOST: ldap
|
||||||
|
# LDAP_PORT: 3389
|
||||||
|
# LDAP_ADMIN_PASSWORD: passthebutter
|
||||||
|
# LDAP_USE_TLS: "false"
|
||||||
|
# depends_on:
|
||||||
|
# - ldap
|
||||||
|
# - redis
|
||||||
|
|
||||||
|
# sidekiq:
|
||||||
|
# build: .
|
||||||
|
# command: bash -c "bundle exec sidekiq -C config/sidekiq.yml"
|
||||||
|
# volumes:
|
||||||
|
# - .:/akkounts
|
||||||
|
# networks:
|
||||||
|
# - internal_network
|
||||||
|
# environment:
|
||||||
|
# RAILS_ENV: development
|
||||||
|
# REDIS_URL: redis://redis:6379/0
|
||||||
|
# LDAP_HOST: ldap
|
||||||
|
# LDAP_PORT: 3389
|
||||||
|
# LDAP_ADMIN_PASSWORD: passthebutter
|
||||||
|
# LDAP_USE_TLS: "false"
|
||||||
|
# LAUNCHY_DRY_RUN: true
|
||||||
|
# BROWSER: /dev/null
|
||||||
|
# depends_on:
|
||||||
|
# - ldap
|
||||||
|
# - redis
|
||||||
|
|
||||||
# phpldapadmin:
|
# phpldapadmin:
|
||||||
# image: osixia/phpldapadmin:0.9.0
|
# image: osixia/phpldapadmin:0.9.0
|
||||||
# ports:
|
# ports:
|
||||||
@@ -16,19 +72,8 @@ services:
|
|||||||
# PHPLDAPADMIN_HTTPS: false
|
# PHPLDAPADMIN_HTTPS: false
|
||||||
# PHPLDAPADMIN_LDAP_HOSTS: "#PYTHON2BASH:[{'ldap': [{'server': [{'tls': False}, {'port': 3389}]}, {'login': [{'bind_id': 'cn=Directory Manager'}, {'bind_pass': 'passthebutter'}]}]}]"
|
# PHPLDAPADMIN_LDAP_HOSTS: "#PYTHON2BASH:[{'ldap': [{'server': [{'tls': False}, {'port': 3389}]}, {'login': [{'bind_id': 'cn=Directory Manager'}, {'bind_pass': 'passthebutter'}]}]}]"
|
||||||
# PHPLDAPADMIN_LDAP_CLIENT_TLS: false
|
# PHPLDAPADMIN_LDAP_CLIENT_TLS: false
|
||||||
# web:
|
|
||||||
# build: .
|
networks:
|
||||||
# tty: true
|
external_network:
|
||||||
# command: bash -c "sleep 5 && rm -f tmp/pids/server.pid && bin/dev"
|
internal_network:
|
||||||
# volumes:
|
internal: true
|
||||||
# - .:/akkounts
|
|
||||||
# ports:
|
|
||||||
# - "3000:3000"
|
|
||||||
# environment:
|
|
||||||
# RAILS_ENV: development
|
|
||||||
# LDAP_HOST: ldap
|
|
||||||
# LDAP_PORT: 3389
|
|
||||||
# LDAP_ADMIN_PASSWORD: passthebutter
|
|
||||||
# LDAP_USE_TLS: "false"
|
|
||||||
# depends_on:
|
|
||||||
# - ldap
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Remove a potentially pre-existing server.pid for Rails.
|
|
||||||
rm -f /myapp/tmp/pids/server.pid
|
|
||||||
|
|
||||||
# Then exec the container's main process (what's set as CMD in the Dockerfile).
|
|
||||||
exec "$@"
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
"postcss-preset-env": "^7.8.3",
|
"postcss-preset-env": "^7.8.3",
|
||||||
"tailwindcss": "^3.2.4"
|
"tailwindcss": "^3.2.4"
|
||||||
},
|
},
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:css:tailwind": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css",
|
"build:css:tailwind": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css",
|
||||||
"build:css": "yarn run build:css:tailwind"
|
"build:css": "yarn run build:css:tailwind"
|
||||||
|
|||||||
@@ -101,4 +101,52 @@ RSpec.describe User, type: :model do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#exchange_xmpp_contact_with_inviter" do
|
||||||
|
include ActiveJob::TestHelper
|
||||||
|
|
||||||
|
let(:user) { create :user, cn: "willherschel", ou: "kosmos.org" }
|
||||||
|
let(:guest) { create :user, id: 2, cn: "isaacnewton", ou: "kosmos.org", email: "newt@example.com" }
|
||||||
|
|
||||||
|
before do
|
||||||
|
Invitation.create! user: user, invited_user_id: guest.id, used_at: DateTime.now
|
||||||
|
allow_any_instance_of(User).to receive(:services_enabled).and_return(%w[ ejabberd ])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "enqueues a job to exchange XMPP contacts between inviter and invitee" do
|
||||||
|
guest.send(:exchange_xmpp_contact_with_inviter)
|
||||||
|
|
||||||
|
expect(enqueued_jobs.size).to eq(1)
|
||||||
|
args = enqueued_jobs.first['arguments']
|
||||||
|
expect(args[0]['_aj_globalid']).to match('gid://akkounts/User')
|
||||||
|
expect(args[1]).to eq('isaacnewton')
|
||||||
|
expect(args[2]).to eq('kosmos.org')
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
clear_enqueued_jobs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#devise_after_confirmation" do
|
||||||
|
let(:user) { create :user, cn: "willherschel", ou: "kosmos.org" }
|
||||||
|
|
||||||
|
it "enables default services" do
|
||||||
|
expect(user).to receive(:enable_service).with(%w[ discourse ejabberd gitea mediawiki ])
|
||||||
|
user.send(:devise_after_confirmation)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "for invited user with ejabberd enabled" do
|
||||||
|
let(:guest) { create :user, id: 2, cn: "isaacnewton", ou: "kosmos.org", email: "newt@example.com" }
|
||||||
|
|
||||||
|
before do
|
||||||
|
Invitation.create! user: user, invited_user_id: guest.id, used_at: DateTime.now
|
||||||
|
allow_any_instance_of(User).to receive(:enable_service).and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "exchanges XMPP contacts with the inviter" do
|
||||||
|
expect(guest).to receive(:exchange_xmpp_contact_with_inviter)
|
||||||
|
guest.send(:devise_after_confirmation)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,34 +65,6 @@ RSpec.describe CreateAccount, type: :model do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#exchange_xmpp_contacts" do
|
|
||||||
include ActiveJob::TestHelper
|
|
||||||
|
|
||||||
let(:inviter) { create :user, cn: "willherschel", ou: "kosmos.org" }
|
|
||||||
let(:invitation) { create :invitation, user: inviter }
|
|
||||||
let(:service) { CreateAccount.new(
|
|
||||||
username: 'isaacnewton',
|
|
||||||
email: 'isaacnewton@example.com',
|
|
||||||
password: 'bright-ideas-in-autumn',
|
|
||||||
invitation: invitation
|
|
||||||
)}
|
|
||||||
|
|
||||||
it "enqueues a job to exchange XMPP contacts between inviter and invitee" do
|
|
||||||
service.send(:exchange_xmpp_contacts)
|
|
||||||
|
|
||||||
expect(enqueued_jobs.size).to eq(1)
|
|
||||||
|
|
||||||
args = enqueued_jobs.first['arguments']
|
|
||||||
expect(args[0]['_aj_globalid']).to match('gid://akkounts/User')
|
|
||||||
expect(args[1]).to eq('isaacnewton')
|
|
||||||
expect(args[2]).to eq('kosmos.org')
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
clear_enqueued_jobs
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#create_lndhub_account" do
|
describe "#create_lndhub_account" do
|
||||||
include ActiveJob::TestHelper
|
include ActiveJob::TestHelper
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user