1

I am trying to password protect the fonts sub-directory in my assets directory because of licensing etc. I have tried a few ideas for routing, but I haven't been able to figure one out yet.

As of now, if you use the route assets/* you can access the file, however I am trying to make it go to an http_basic_auth. I have tried setting up a controller called asset_controller with the http_basic_auth in it, but I can't seem to get the routing correct. Here is my code so far:

routes.rb (this obviously does not work...)

match '/assets/', to: 'assets#show'

asset_controller.rb

class AssetController < ApplicationController
  http_basic_authenticate_with :name => "admin", :password => "secret"
end

Also, this approach may be wrong. So, if there is a better solution please suggest one!

4

1 に答える 1

-1

アセット パイプラインの外でフォントを提供する必要があります。使用する認証メカニズムの背後にあるフォント アセットを提供する を作成することをFontsControllerお勧めします。バイナリ アセットの提供とコントローラーのパスワード保護アクションは、十分に解決された問題です。

于 2013-01-02T20:12:20.140 に答える