Class: WorkOS::MultiFactorAuth
- Inherits:
-
Object
- Object
- WorkOS::MultiFactorAuth
- Defined in:
- lib/workos/multi_factor_auth.rb
Instance Method Summary collapse
-
#challenge_factor(id:, sms_template: nil, request_options: {}) ⇒ WorkOS::AuthenticationChallenge
Challenge Factor.
-
#create_user_auth_factor(userland_user_id:, type:, totp_issuer: nil, totp_user: nil, totp_secret: nil, request_options: {}) ⇒ WorkOS::UserAuthenticationFactorEnrollResponse
Enroll an authentication factor.
-
#delete_factor(id:, request_options: {}) ⇒ void
Delete Factor.
-
#enroll_factor(type:, phone_number: nil, totp_issuer: nil, totp_user: nil, user_id: nil, request_options: {}) ⇒ WorkOS::AuthenticationFactorEnrolled
Enroll Factor.
-
#get_factor(id:, request_options: {}) ⇒ WorkOS::AuthenticationFactor
Get Factor.
-
#initialize(client) ⇒ MultiFactorAuth
constructor
A new instance of MultiFactorAuth.
-
#list_user_auth_factors(userland_user_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuthenticationFactor>
List authentication factors.
-
#verify_challenge(id:, code:, request_options: {}) ⇒ WorkOS::AuthenticationChallengeVerifyResponse
Verify Challenge.
Constructor Details
#initialize(client) ⇒ MultiFactorAuth
Returns a new instance of MultiFactorAuth.
9 10 11 |
# File 'lib/workos/multi_factor_auth.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#challenge_factor(id:, sms_template: nil, request_options: {}) ⇒ WorkOS::AuthenticationChallenge
Challenge Factor
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/workos/multi_factor_auth.rb', line 114 def challenge_factor( id:, sms_template: nil, request_options: {} ) body = { "sms_template" => sms_template }.compact response = @client.request( method: :post, path: "/auth/factors/#{WorkOS::Util.encode_path(id)}/challenge", auth: true, body: body, request_options: ) result = WorkOS::AuthenticationChallenge.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_user_auth_factor(userland_user_id:, type:, totp_issuer: nil, totp_user: nil, totp_secret: nil, request_options: {}) ⇒ WorkOS::UserAuthenticationFactorEnrollResponse
Enroll an authentication factor
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/workos/multi_factor_auth.rb', line 189 def create_user_auth_factor( userland_user_id:, type:, totp_issuer: nil, totp_user: nil, totp_secret: nil, request_options: {} ) body = { "type" => type, "totp_issuer" => totp_issuer, "totp_user" => totp_user, "totp_secret" => totp_secret }.compact response = @client.request( method: :post, path: "/user_management/users/#{WorkOS::Util.encode_path(userland_user_id)}/auth_factors", auth: true, body: body, request_options: ) result = WorkOS::UserAuthenticationFactorEnrollResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#delete_factor(id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete Factor
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/workos/multi_factor_auth.rb', line 96 def delete_factor( id:, request_options: {} ) @client.request( method: :delete, path: "/auth/factors/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) nil end |
#enroll_factor(type:, phone_number: nil, totp_issuer: nil, totp_user: nil, user_id: nil, request_options: {}) ⇒ WorkOS::AuthenticationFactorEnrolled
Enroll Factor
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/workos/multi_factor_auth.rb', line 46 def enroll_factor( type:, phone_number: nil, totp_issuer: nil, totp_user: nil, user_id: nil, request_options: {} ) body = { "type" => type, "phone_number" => phone_number, "totp_issuer" => totp_issuer, "totp_user" => totp_user, "user_id" => user_id }.compact response = @client.request( method: :post, path: "/auth/factors/enroll", auth: true, body: body, request_options: ) result = WorkOS::AuthenticationFactorEnrolled.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_factor(id:, request_options: {}) ⇒ WorkOS::AuthenticationFactor
Get Factor
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/workos/multi_factor_auth.rb', line 77 def get_factor( id:, request_options: {} ) response = @client.request( method: :get, path: "/auth/factors/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::AuthenticationFactor.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#list_user_auth_factors(userland_user_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuthenticationFactor>
List authentication factors
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/workos/multi_factor_auth.rb', line 142 def list_user_auth_factors( userland_user_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/user_management/users/#{WorkOS::Util.encode_path(userland_user_id)}/auth_factors", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_user_auth_factors( userland_user_id: userland_user_id, before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::AuthenticationFactor, filters: {userland_user_id: userland_user_id, before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#verify_challenge(id:, code:, request_options: {}) ⇒ WorkOS::AuthenticationChallengeVerifyResponse
Verify Challenge
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/workos/multi_factor_auth.rb', line 18 def verify_challenge( id:, code:, request_options: {} ) body = { "code" => code }.compact response = @client.request( method: :post, path: "/auth/challenges/#{WorkOS::Util.encode_path(id)}/verify", auth: true, body: body, request_options: ) result = WorkOS::AuthenticationChallengeVerifyResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |