workos / workos-ruby

Official Ruby SDK for interacting with the WorkOS API
https://workos.com/docs/sdk/ruby
MIT License
30 stars 14 forks source link

Code equals nil in WorkOS::MFA.challenge_factor response #325

Open tomczak-mateusz opened 2 months ago

tomczak-mateusz commented 2 months ago

Hey, I'm using WorkOS MFA in my customer project & utilise Ruby gem. Everything works as expected but I was able to find one confusing response:

When running a challenge_factor request I can see an attribute code: nil for WorkOS::Challenge in response (and it returns nil for this attribute for any auth_factor_id), example:

irb(main):003> auth_factor_id = Member.find(2).mfa_sms_auth_factor_id
=> "auth_factor_01J50D363JX20ZVRZE2M2P****"

irb(main):004> challenge = WorkOS::MFA.challenge_factor(authentication_factor_id: auth_factor_id)
=>
#<WorkOS::Challenge:0x00000001223d0248
...

irb(main):005> challenge
=>
#<WorkOS::Challenge:0x00000001223d0248
 @authentication_factor_id="auth_factor_01J50D363JX20ZVRZE2M2P****",
 @code=nil,
 @created_at="2024-08-12T12:39:09.808Z",
 @expires_at="2024-08-12T12:49:09.809Z",
 @id="auth_challenge_01J539JZ7MH51DWBTDJ1W6****",
 @object="authentication_challenge",
 @updated_at="2024-08-12T12:39:09.808Z">

I can see that Code is NOT covered in the Authentication Challenge documentation as well: https://workos.com/docs/reference/user-management/mfa/authentication-challenge image

I would suggest to either remove Code from response or to document it properly.

PaulAsjes commented 2 months ago

Thanks for the report! That's indeed an unused parameter, I'll make a note to remove this in the next major version.