Code Monkey home page Code Monkey logo

Comments (3)

pokonski avatar pokonski commented on June 6, 2024 1

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.

pokonski avatar pokonski commented on June 6, 2024

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.

tsvallender avatar tsvallender commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.