Skip to content

Commit 39933a5

Browse files
authored
Add basic auth (#47)
1 parent 8ac89f1 commit 39933a5

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
## [0.2.1](https://github.com/renuo/hotsheet/releases/tag/v0.2.1) - 2025-06-27
66

7+
- Add optional basic auth ([@hunchr])
78
- Fix I18n fallback ([@hunchr])
89

910
## [0.2.0](https://github.com/renuo/hotsheet/releases/tag/v0.2.0) - 2025-06-25

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ After the installation, you can start the Rails server and visit
2424
You can configure which models ('sheets') this gem should manage, and specify which
2525
database columns should be editable or viewable in the spreadsheet. This can be
2626
done by editing the [config/initializers/hotsheet.rb](https://github.com/renuo/hotsheet/blob/main/lib/generators/templates/hotsheet.rb)
27-
file created by the install command.
27+
file created by the install command:
2828

2929
```rb
3030
Hotsheet.configure do
@@ -41,6 +41,15 @@ Hotsheet.configure do
4141
end
4242
```
4343

44+
### Basic Authentication
45+
46+
If you don't want everyone to have access to Hotsheet, you can set a
47+
basic auth environment variable:
48+
49+
```sh
50+
HOTSHEET_BASIC_AUTH="admin:password"
51+
```
52+
4453
### Internationalization
4554

4655
You can create custom translations by overwriting the default locales defined in
@@ -59,7 +68,7 @@ This is a newly created gem, and we will firstly focus on:
5968
1. Configuration and access permissions
6069
1. Concurrent users (broadcasting, conflict resolution)
6170

62-
Feel free to look at our [planned enhancements](https://github.com/renuo/hotsheet/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement)
71+
Feel free to look at our [planned enhancements](https://github.com/renuo/hotsheet/issues?q=is:open+is:issue+label:feature)
6372
or add your own.
6473

6574
## License

app/controllers/hotsheet/application_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22

33
class Hotsheet::ApplicationController < ActionController::Base
44
protect_from_forgery with: :exception
5+
6+
# :nocov:
7+
ENV["HOTSHEET_BASIC_AUTH"]&.split(":")&.then do |name, password|
8+
http_basic_authenticate_with name:, password:
9+
end
10+
# :nocov:
511
end

0 commit comments

Comments
 (0)