Comments (3)
Is there ever a reason you would need to decrypt credentials for the purpose of precompiling assets though? Is this not an error that could be caught and ignored?
This isn't a Rails issue. It's how Ruby works. You added a class level code that tries to read credentials when class is loaded. There's no way for Rails to catch and ignore
You can see this in IRB by defining a simple class with puts
in it:
irb(main):001:1* class Test
irb(main):002:1* puts "something at load time"
irb(main):006:0> end
something at load time
from rails.
This is about missing credentials, which cannot be decrypted without the key. You are reading a password from credentrials at class level, which is evaluated as soon as the controller is loaded and interpreted.
To avoid this see the advanced example here: https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html
that is define a custom method that checks the credentials. This way it won't be executed during loading of the code.
Alternatively you could do what http_basic_authenticate_with already does under the hood:
before_action :authenticate_with_basic
private
def authenticate_with_basic
http_basic_authenticate_with name: "admin", password: Rails.application.credentials.dig(:http_auth, :password)
end
from rails.
Is there ever a reason you would need to decrypt credentials for the purpose of precompiling assets though? Is this not an error that could be caught and ignored?
from rails.
Related Issues (20)
- Blog sample failing on windows 11 HOT 4
- Rails 7.2: Memoization of the ActiveJob adapter class happens too early HOT 2
- Rails 7.1 raises exception while trying to increment counter cache on model using CPK HOT 1
- Rails 7.2: Parsing tests with prism makes it impossible to run spec-style tests by line number
- Ability to split locals magic comment into multiple lines
- `EarlyHintsRequestTest#test_when_early_hints_is_set_in_the_env_link_headers_are_sent` fails with since https://github.com/rack/rack/pull/1831 HOT 2
- Command `rails devcontainer` failed - missing templates HOT 2
- `.pluck` with multiple sql fragment arguments using `min` incorrectly casts types when using PostgreSQL HOT 2
- accepts_nested_attributes_for doesn't account for records that are marked for destruction when validating uniqueness HOT 2
- Composite key relations raise when calling `include?` HOT 1
- rails restart doesn't work with puma HOT 3
- Missing documentation for "fixture" method
- [Rails 7.1.3.2] Invalid CSRF Token when submitting a form with data-turbo="false" when Turbo Drive is enabled HOT 2
- [ActiveRecord::Encryption] ignores key_provider in with_encryption_context HOT 4
- [Rails 6.1] Rails 6.1 vulerable to CVE-2024-34341 (trix and actiontext) HOT 1
- The password field is ignored when I use fetch or require #52010 HOT 1
- [Guides Enhancement] Add Search using Algolia or similar
- Database references and ActiveRecord references not match HOT 3
- Would be nice to be able to specify a table to use for `references` columns when generating a migration HOT 3
- Inconsistent charset case in redirect content type HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rails.