hephaestus 0.8.18 → 0.8.19

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffedeecbefff19cb5a280d95430ff9248ba14256b6fa3189b6b9cfef5a0d88cb
4
- data.tar.gz: aa348ded26343abe7cb12911821d3d589e6760829f5cf4c97d441c0396fef7c0
3
+ metadata.gz: bbdf4f3a5c6472e793f2e4a5cca2d8588d8fc7edf8a713db536671e48c5b8adc
4
+ data.tar.gz: 1d85b74ed6a67234ef911135c6a25d51f2ae5f015d8eec3dd2f8e45611144d9d
5
5
  SHA512:
6
- metadata.gz: 31a6fa2a2a39de35377f0356304b0cbbc24715e4ab50dc59f0b6d7fe9f4ddcd0450acba680c87a49b162700315ca9ad3fab8abb9e24e67555c5fd3a42eebb74b
7
- data.tar.gz: 445442bdc86c11c68abfd4085587a80f831a1a10e9b62283b03720516c53119a090de6ef16f5681dfd9cb382c9815713fe215e9af35652a75a9674bdb3ff80a7
6
+ metadata.gz: 53815be1097fac20d441f5a63be128e8cd0af9cbb152a02b1b449747aa376623dd3079ff84f9fca003174464688cd1b321ec448f6cfd42e3c7ef72ca3195bff2
7
+ data.tar.gz: 8398911ad7a8a1359e803dfc07dd88a0d42fde211a75f16fbc0c20a28fa4fc1cdb95f874e29c002423090f35179c490b3d5b58f189c78506fb873fdd3d57ebb0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [v0.8.19] - 08-04-2025
2
+ ## What's Changed
3
+ * Protect staff pages with basic auth by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/120
4
+
5
+
6
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.8.18...v0.8.19
1
7
  # [v0.8.18] - 24-03-2025
2
8
  ## What's Changed
3
9
  * Silence 404 API routes by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/118
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,10 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ module Hephaestus
5
+ module SessionAuth
6
+ def logged_in?
7
+ not_found if session[:logged_in].blank?
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ module Hephaestus
5
+ module ValidatesWithBasicAuth
6
+ include ActionController::HttpAuthentication::Basic::ControllerMethods
7
+
8
+ def validate_basic_auth
9
+ http_basic_authenticate_or_request_with(name: "billy", password: Hephaestus::STAFF_PASSWORD)
10
+ end
11
+ end
12
+ end
@@ -3,18 +3,22 @@
3
3
 
4
4
  module Hephaestus
5
5
  class StaffController < ApplicationController
6
- layout "staff"
6
+ include SessionAuth
7
+
8
+ include Hephaestus::ValidatesWithBasicAuth
9
+
10
+ before_action :require_staff
7
11
 
8
12
  class << self
9
- def staff_request?(request)
10
- return true if Rails.env.development?
13
+ def valid_request?(request)
14
+ # return true if Rails.env.development?
11
15
 
12
- true
16
+ http_basic_authenticate_with(name: "billy", password: Hephaestus::STAFF_PASSWORD)
13
17
  end
14
18
  end
15
19
 
16
- def index
17
- render404 unless StaffController.staff_request?(request)
20
+ private def require_staff
21
+ not_found unless StaffController.valid_request?(request)
18
22
  end
19
23
  end
20
24
  end
@@ -11,10 +11,10 @@ module Hephaestus
11
11
  type = params.delete(:type)
12
12
  params.deep_symbolize_keys!
13
13
 
14
- inbox_id = params.fetch(:inbox, {}).fetch(:id, nil)
15
- plug_installation_id = params.fetch(:plug_installation, {}).fetch(:id, nil)
16
- conversation_id = params.fetch(:conversation, {}).fetch(:id, nil)
17
- message_id = params.fetch(:message, {}).fetch(:id, nil)
14
+ inbox_id = params.dig(:inbox, :id)
15
+ plug_installation_id = params.dig(:plug_installation, :id)
16
+ conversation_id = params.dig(:conversation, :id)
17
+ message_id = params.dig(:message, :id)
18
18
 
19
19
  response = case type
20
20
  when "update_plug_installation"
@@ -0,0 +1,20 @@
1
+ <div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
2
+ <div class="sm:mx-auto sm:w-full sm:max-w-sm">
3
+ <h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Sign in to your account</h2>
4
+ </div>
5
+
6
+ <div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
7
+ <form class="space-y-6" action="<%= %>" method="POST">
8
+ <div>
9
+ <label for="email" class="block text-sm/6 font-medium text-gray-900">Email address</label>
10
+ <div class="mt-2">
11
+ <input type="email" name="email" id="email" autocomplete="email" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
12
+ </div>
13
+ </div>
14
+
15
+ <div>
16
+ <button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm/6 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Sign in</button>
17
+ </div>
18
+ </form>
19
+ </div>
20
+ </div>
@@ -0,0 +1,21 @@
1
+ <div class="min-h-screen bg-gray-100">
2
+ <header class="py-8 bg-white shadow-lg ">
3
+ <h1 class="text-4xl font-bold text-gray-900 text-center">
4
+ Hello, staff!
5
+ </h1>
6
+ <p class="text-xl text-gray-600 text-center mt-2">
7
+ (This is for <%= plug_name %> <code><%= Rails.env %></code>)
8
+ </p>
9
+ </header>
10
+
11
+ <main class="max-w-6xl mx-auto mt-12 px-6">
12
+ <div class="bg-white rounded-xl shadow-lg p-8">
13
+ <ul class="space-y-6 flex flex-col items-center">
14
+ <li>
15
+ <%= link_to "Jobs Dashboard", "/staff/jobs", class: "text-xl text-indigo-600 hover:text-indigo-500 font-semibold hover:underline transition-all duration-200 ease-in-out" %>
16
+ </li>
17
+ <%# Add more links here as needed %>
18
+ </ul>
19
+ </div>
20
+ </main>
21
+ </div>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title></title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= yield :head %>
9
+
10
+ <%= stylesheet_link_tag "tailwind", media: "all" %>
11
+ </head>
12
+ <body>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,10 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ class AdminConstraint
5
+ class << self
6
+ def matches?(request)
7
+ request.env["HTTP_AUTHORIZATION"] == "Basic " + Base64.strict_encode64("billy:#{Hephaestus::STAFF_PASSWORD}")
8
+ end
9
+ end
10
+ end
@@ -143,4 +143,6 @@ module Hephaestus
143
143
  label: "YETTO_PLUG_ID",
144
144
  default: "plug-id",
145
145
  )
146
+
147
+ STAFF_PASSWORD = fetch_infra_secret(label: "STAFF_PASSWORD", default: "password")
146
148
  end
data/config/routes.rb CHANGED
@@ -1,8 +1,17 @@
1
1
  # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
- # this file doesn't actually do anything; consumed routes are
5
- # in lib/hephaestus/engine.rb
4
+ #############################################################################
5
+ # _____ _____ _____ ____ _ _ _
6
+ # | | | _ | | \| | | |
7
+ # | | | | | | | | | | | |
8
+ # \___/|__|__|_|_|_|____/|_____|
9
+ #
10
+ # THIS FILE DOES NOT DO ANYTHING!
11
+ # ALL ROUTES ARE DEFINED IN:
12
+ # lib/hephaestus/engine.rb#insert_routes
13
+ #############################################################################
14
+
6
15
  Hephaestus::Engine.routes.draw do
7
16
  resources :settings, only: [:new, :edit]
8
17
 
@@ -45,9 +45,9 @@ module Hephaestus
45
45
  def insert_routes
46
46
  Rails.application.routes.draw do
47
47
  # Staff pages
48
- get("staff", to: "staff#index")
48
+ get("staff", to: "hephaestus/staff#index")
49
49
 
50
- constraints(->(request) { StaffController.staff_request?(request) }) do
50
+ constraints(AdminConstraint) do
51
51
  mount(MissionControl::Jobs::Engine, at: "staff/jobs", as: :staff_jobs)
52
52
  end
53
53
 
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Hephaestus
5
- VERSION = "0.8.18"
5
+ VERSION = "0.8.19"
6
6
  RAILS_VERSION = ">= 8.0"
7
7
  RUBY_VERSION = File
8
8
  .read("#{File.dirname(__FILE__)}/../../.ruby-version")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hephaestus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.18
4
+ version: 0.8.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-24 00:00:00.000000000 Z
11
+ date: 2025-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootsnap
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '1.5'
181
+ - !ruby/object:Gem::Dependency
182
+ name: propshaft
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '1.1'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '1.1'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: puma
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -290,6 +304,20 @@ dependencies:
290
304
  - - "~>"
291
305
  - !ruby/object:Gem::Version
292
306
  version: '2.0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: tailwindcss-rails
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - "~>"
312
+ - !ruby/object:Gem::Version
313
+ version: '4.2'
314
+ type: :runtime
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
319
+ - !ruby/object:Gem::Version
320
+ version: '4.2'
293
321
  - !ruby/object:Gem::Dependency
294
322
  name: opentelemetry-exporter-otlp
295
323
  requirement: !ruby/object:Gem::Requirement
@@ -346,20 +374,6 @@ dependencies:
346
374
  - - "~>"
347
375
  - !ruby/object:Gem::Version
348
376
  version: '1.10'
349
- - !ruby/object:Gem::Dependency
350
- name: propshaft
351
- requirement: !ruby/object:Gem::Requirement
352
- requirements:
353
- - - "~>"
354
- - !ruby/object:Gem::Version
355
- version: '1.1'
356
- type: :runtime
357
- prerelease: false
358
- version_requirements: !ruby/object:Gem::Requirement
359
- requirements:
360
- - - "~>"
361
- - !ruby/object:Gem::Version
362
- version: '1.1'
363
377
  - !ruby/object:Gem::Dependency
364
378
  name: dotenv-rails
365
379
  requirement: !ruby/object:Gem::Requirement
@@ -389,8 +403,11 @@ files:
389
403
  - CHANGELOG.md
390
404
  - LICENSE.txt
391
405
  - README.md
406
+ - app/assets/tailwind/application.css
392
407
  - app/controllers/concerns/hephaestus/responses.rb
408
+ - app/controllers/concerns/hephaestus/session_auth.rb
393
409
  - app/controllers/concerns/hephaestus/validates_from_yetto.rb
410
+ - app/controllers/concerns/hephaestus/validates_with_basic_auth.rb
394
411
  - app/controllers/hephaestus/application_controller.rb
395
412
  - app/controllers/hephaestus/root_controller.rb
396
413
  - app/controllers/hephaestus/settings_controller.rb
@@ -401,14 +418,17 @@ files:
401
418
  - app/serializers/hephaestus/error_serializer.rb
402
419
  - app/serializers/hephaestus/headers.rb
403
420
  - app/services/hephaestus/yetto_service.rb
404
- - app/views/layouts/staff.html.erb
405
- - app/views/staff/index.html.erb
421
+ - app/views/hephaestus/sessions/login.html.erb
422
+ - app/views/hephaestus/staff/index.html.erb
423
+ - app/views/layouts/hephaestus/application.html.erb
424
+ - app/views/layouts/hephaestus/staff.html.erb
406
425
  - bin/hephaestus
407
426
  - config/database.yml
408
427
  - config/environments/development.rb
409
428
  - config/environments/production.rb
410
429
  - config/environments/staging.rb
411
430
  - config/environments/test.rb
431
+ - config/initializers/admin_constraint.rb
412
432
  - config/initializers/application.rb
413
433
  - config/initializers/cors.rb
414
434
  - config/initializers/environment.rb
@@ -1,7 +0,0 @@
1
- <div class="container">
2
- <h1>Staff page</h1>
3
- <div class="row">
4
- <div class="col-md-12">
5
- <%= yield %>
6
- </div>
7
- </div>
@@ -1 +0,0 @@
1
- Hello, staff!