我用过before_filter:authenticate_user!在我的控制器中,如何以json的形式获取数据

时间:2012-09-17 10:27:49

标签: ruby-on-rails ruby-on-rails-3 devise

我使用过before_filter:authenticate_user!在我的控制器中,如果我删除它并给出

curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X GET http://localhost:3000/posts

然后我看到了json数据。那么我怎样才能使用before_filter:authenticate_user!以确保安全。

1 个答案:

答案 0 :(得分:0)

您可以将Basic Authentiation用于JSON请求,因此身份验证凭据可以包含在http标头中。

相关问题