Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to pass a callable to authorization middleware #1344

Closed
sled opened this issue Dec 10, 2021 · 2 comments
Closed

Ability to pass a callable to authorization middleware #1344

sled opened this issue Dec 10, 2021 · 2 comments
Labels

Comments

@sled
Copy link
Contributor

sled commented Dec 10, 2021

The authorization middleware currently checks for a Proc:

value = value.call if value.is_a?(Proc)

Wouldn't it make sense to ease this restriction and just require a callable?

Example use case:

class ComplexAuthorizer
  def call
     # do magic and return a token
  end
end

authorizer = ComplexAuthorizer.new(....)

Faraday.new(url: ....) do |conn|
  conn.request :authorization, 'Bearer', authorizer
end
@sled sled changed the title Ability to pass a callable as to authorization middleware Ability to pass a callable to authorization middleware Dec 10, 2021
@iMacTia
Copy link
Member

iMacTia commented Dec 10, 2021

That would make sense indeed, I'd happily review a PR that enhances the middleware to accept either a proc or a callable 👍

sled added a commit to sled/faraday that referenced this issue Dec 12, 2021
@sled
Copy link
Contributor Author

sled commented Dec 12, 2021

That would make sense indeed, I'd happily review a PR that enhances the middleware to accept either a proc or a callable 👍

Here you go: #1345

@sled sled closed this as completed Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants