Using authlogic_api for Rails REST API access

前端 未结 3 2200
误落风尘
误落风尘 2021-02-09 07:44

I am writing a Rails back-end API for a Steam game that is only accessed via REST calls, so no user-specific authentication is required. I am trying to implement the authlogic_a

3条回答
  •  温柔的废话
    2021-02-09 08:44

    You may not need the overhead of Authlogic.

    If you are generating a URL that the client will then send, just add an expiration timestamp, and do an MD5 hash (signature) on the entire URL, adding the result as a final query paramter.

    Please a before_filter on the controller action, i.e. a signed_url method that will validate the URL. This method should get the URL from the request object. Verify the expiration has not passed. Remove the signature from the URL to place it in the same form as was used to generate the original URL, do so, and verify a match. Voila.

    Expiration is important to be sure that URL's cannot be re-used later.

    This is a great method to centralize as an alternate way to authorize requests without requiring a login. As long as you have generated the URL, it will be valid until expiration from any host.

提交回复
热议问题