New feature suggestion: Get username and password separately from ActionController::HttpAuthentication::Basic::user_name_and_password

Hi fellow coders,

I have recently been implementing an API and used Basic Auth as the authentication method. Besides doing the authentication part, I need to extract the email from the request header for other usages.

Currently, we can extract username the following way:

username = ActionController::HttpAuthentication::Basic::user_name_and_password[0]

But I wanted to propose to add two new methods: One for getting the username, and the other one for taking the password, so that we do not need to use array indexes to get each one. Then we can refactor ActionController::HttpAuthentication::Basic::user_name_and_password and prepare the response from these new methods.

This sounds as something really simple, that may not be that important, but I believe it greatly fits with the central principle of Ruby, as Matz says:

“Ruby is designed to make programmers happy.”

If this does resonate with you, I would be more than happy and grateful to implement it.

Thank you very much.

Hi fellow coders,

I have recently been implementing an API and used Basic Auth as the authentication method. Besides doing the authentication part, I need to extract the email from the request header for other usages.

Currently, we can extract username the following way:

username = ActionController::HttpAuthentication::Basic::user_name_and_password[0]

Why not simply do:

username, password = ActionController::HttpAuthentication::Basic::user_name_and_password

(there’s no need for a new method and there’s already array assignment so no need to explicitly index the result)

-Rob