MFA API Bearer token issue
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- ruby
- Domain
- api, authentication
Research direction
Start with lib/auth0/mixins/httpproxy.rb#L95 and trace how extra_headers are handled for POST requests through request_with_retry. Compare that path with lib/auth0/api/authentication_endpoints.rb and verify that an MFA Bearer token can override or supply the request header; done means the reported MFA API call sends the intended token.
Written by the indexing model from the issue text.
Description
Checklist
- I have looked into the Readme and Examples, and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
I found what it seems an issue while trying to interact with the MFA API for testing purposes, to test this API I decided to monkey patch the https://github.com/auth0/ruby-auth0/blob/master/lib/auth0/api/authentication_endpoints.rb module, this was the easiest way to interact with the MFA API using existing mechanisms (If this works and is something that makes sense including in the gem I'd love to implement a better solution and create a PR), continuing with the issue and because of how MFA endpoints work when a user does not have an authenticator method, I need to pass the mfa_token I get with the mfa_required error type in the Bearer header, this was not working and after some investigation I figured out that extra headers when making POST API calls do not work, the gem does not take extra_headers into account in that case https://github.com/auth0/ruby-auth0/blob/master/lib/auth0/mixins/httpproxy.rb#L95, I'd like to understand if that's something that makes sense implementing and if that's the case I'm available to create a PR to cover that use case.
Here just a snippet of the monkey patch I described above to associate a new MFA
module Auth0
module Api
module AuthenticationEndpoints
def mfa_otp_associate(client_id: @client_id, client_secret: @client_secret, mfa_token:)
request_params = {
client_id: client_id,
client_secret: client_secret,
authenticator_types: ['otp']
}
request_with_retry(:post, '/mfa/associate', request_params, { 'Authorization' => "Bearer #{mfa_token}" })
end
end
end
end
If the client object already has a Bearer header it will use that one and not the one I'm passing.
Please let me know if you need more information to understand my use case with the MFA API.
Reproduction
There is no easy way to reproduce this without interacting with the MFA API.
Additional context
No response
ruby-auth0 version
5.16.0
Ruby version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
- Dominant language
- Ruby
- Stars
- 205
- Forks
- 148
- Avg merge
- 13h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from auth0/ruby-auth0
-
Model#initialize drops every `false` value — booleans are silently lost on requests and responsesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
auth0/ruby-auth0#800 · 1 comment ·
-
feature request
Difficulty 3/5 1-2 days Newbie friendliness 45/100
auth0/ruby-auth0#709 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 50/100
auth0/ruby-auth0#610 · 1 comment ·
-
feature request
Difficulty 5/5 Over a week Newbie friendliness 32/100
auth0/ruby-auth0#606 · 2 comments · 1 reaction ·
-
feature request
Difficulty 3/5 1-2 days Newbie friendliness 35/100
auth0/ruby-auth0#500 · 1 comment ·
All issues in auth0/ruby-auth0
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
Maintainers usually reply within 3 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
jetrockets/jet_ui#47 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
FreeCAD/homebrew-freecad#870 ·
Maintainers usually reply within 1 day