Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is how method <code>authenticate_or_request_with_http_basic</code> and in general how HTTP authentication works. <code>authenticate_or_request_with_http_basic</code> can be reworded as: "First try to authenticate and if not authenticated, request for authentication". The source code of this method is as follows:</p> <pre><code>def authenticate_or_request_with_http_basic(realm = "Application", &amp;login_procedure) authenticate_with_http_basic(&amp;login_procedure) || request_http_basic_authentication(realm) end </code></pre> <p>So what happens. When you first hit the URL that invokes this action, this <code>authenticate_or_request_with_http_basic</code> returns HTTP response 401 Unauthorized. The browser understands this is a request for authentication and shows you a dialog to enter username and password, and then resends the request for the same URL but includes your credentials into request headers. You filter is hit again, and this time method <code>authenticate_or_request_with_http_basic</code> sees that there are authentication headers in the request and authorises you successfully. And the browser will send these auth headers on each following request to this domain (until you close the browser).</p> <p>So if you need just test it several times you can close and reopen browser. I believe using only these methods it is impossible to ask for authentication and authenticate on every request because when the application gets request from browser with Auth headers it can not tell whether this is request immediately after authentication request, or these are headers preserved before.</p> <p>But this can be somehow accomplished using cookies or value stored in session.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload