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 回答