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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Fatos Morina
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. 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Rob Biedenharn-3

On 2017-Aug-7, at 03:06 , Fatos Morina <[hidden email]> wrote:

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


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. 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Loading...