lib/fusionauth/fusionauth_client.rb in fusionauth_client-1.39.0 vs lib/fusionauth/fusionauth_client.rb in fusionauth_client-1.41.0
- old
+ new
@@ -174,10 +174,30 @@
.get()
.go()
end
#
+ # Make a Client Credentials grant request to obtain an access token.
+ #
+ # @param client_id [string] The client identifier. The client Id is the Id of the FusionAuth Entity in which you are attempting to authenticate.
+ # @param client_secret [string] The client secret used to authenticate this request.
+ # @param scope [string] (Optional) This parameter is used to indicate which target entity you are requesting access. To request access to an entity, use the format target-entity:<target-entity-id>:<roles>. Roles are an optional comma separated list.
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def client_credentials_grant(client_id, client_secret, scope)
+ body = {
+ "client_id" => client_id,
+ "client_secret" => client_secret,
+ "grant_type" => "client_credentials",
+ "scope" => scope
+ }
+ startAnonymous.uri('/oauth2/token')
+ .body_handler(FusionAuth::FormDataBodyHandler.new(body))
+ .post()
+ .go()
+ end
+
+ #
# Adds a comment to the user's account.
#
# @param request [OpenStruct, Hash] The request object that contains all the information used to create the user comment.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
def comment_on_user(request)
@@ -186,10 +206,46 @@
.post()
.go()
end
#
+ # Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge without logging the user in
+ #
+ # @param request [OpenStruct, Hash] An object containing data necessary for completing the authentication ceremony
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def complete_web_authn_assertion(request)
+ startAnonymous.uri('/api/webauthn/assert')
+ .body_handler(FusionAuth::JSONBodyHandler.new(request))
+ .post()
+ .go()
+ end
+
+ #
+ # Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge and then login the user in
+ #
+ # @param request [OpenStruct, Hash] An object containing data necessary for completing the authentication ceremony
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def complete_web_authn_login(request)
+ startAnonymous.uri('/api/webauthn/login')
+ .body_handler(FusionAuth::JSONBodyHandler.new(request))
+ .post()
+ .go()
+ end
+
+ #
+ # Complete a WebAuthn registration ceremony by validating the client request and saving the new credential
+ #
+ # @param request [OpenStruct, Hash] An object containing data necessary for completing the registration ceremony
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def complete_web_authn_registration(request)
+ start.uri('/api/webauthn/register/complete')
+ .body_handler(FusionAuth::JSONBodyHandler.new(request))
+ .post()
+ .go()
+ end
+
+ #
# Creates an API key. You can optionally specify a unique Id for the key, if not provided one will be generated.
# an API key can only be created with equal or lesser authority. An API key cannot create another API key unless it is granted
# to that API key.
#
# If an API key is locked to a tenant, it can only create API Keys for that same tenant.
@@ -1109,10 +1165,22 @@
.delete()
.go()
end
#
+ # Deletes the WebAuthn credential for the given Id.
+ #
+ # @param id [string] The Id of the WebAuthn credential to delete.
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def delete_web_authn_credential(id)
+ start.uri('/api/webauthn')
+ .url_segment(id)
+ .delete()
+ .go()
+ end
+
+ #
# Deletes the webhook for the given Id.
#
# @param webhook_id [string] The Id of the webhook to delete.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
def delete_webhook(webhook_id)
@@ -1437,10 +1505,22 @@
.post()
.go()
end
#
+ # Import a WebAuthn credential
+ #
+ # @param request [OpenStruct, Hash] An object containing data necessary for importing the credential
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def import_web_authn_credential(request)
+ start.uri('/api/webauthn/import')
+ .body_handler(FusionAuth::JSONBodyHandler.new(request))
+ .post()
+ .go()
+ end
+
+ #
# Inspect an access token issued by FusionAuth.
#
# @param client_id [string] The unique client identifier. The client Id is the Id of the FusionAuth Application for which this token was generated.
# @param token [string] The access token returned by this OAuth provider as the result of a successful authentication.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
@@ -3229,10 +3309,34 @@
.get()
.go()
end
#
+ # Retrieves the WebAuthn credential for the given Id.
+ #
+ # @param id [string] The Id of the WebAuthn credential.
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def retrieve_web_authn_credential(id)
+ start.uri('/api/webauthn')
+ .url_segment(id)
+ .get()
+ .go()
+ end
+
+ #
+ # Retrieves all WebAuthn credentials for the given user.
+ #
+ # @param user_id [string] The user's ID.
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def retrieve_web_authn_credentials_for_user(user_id)
+ start.uri('/api/webauthn')
+ .url_parameter('userId', user_id)
+ .get()
+ .go()
+ end
+
+ #
# Retrieves the webhook for the given Id. If you pass in null for the id, this will return all the webhooks.
#
# @param webhook_id [string] (Optional) The Id of the webhook.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
def retrieve_webhook(webhook_id)
@@ -3677,9 +3781,33 @@
#
# @param request [OpenStruct, Hash] The Two-Factor start request that contains all of the information used to begin the Two-Factor login request.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
def start_two_factor_login(request)
start.uri('/api/two-factor/start')
+ .body_handler(FusionAuth::JSONBodyHandler.new(request))
+ .post()
+ .go()
+ end
+
+ #
+ # Start a WebAuthn authentication ceremony by generating a new challenge for the user
+ #
+ # @param request [OpenStruct, Hash] An object containing data necessary for starting the authentication ceremony
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def start_web_authn_login(request)
+ start.uri('/api/webauthn/start')
+ .body_handler(FusionAuth::JSONBodyHandler.new(request))
+ .post()
+ .go()
+ end
+
+ #
+ # Start a WebAuthn registration ceremony by generating a new challenge for the user
+ #
+ # @param request [OpenStruct, Hash] An object containing data necessary for starting the registration ceremony
+ # @return [FusionAuth::ClientResponse] The ClientResponse object.
+ def start_web_authn_registration(request)
+ start.uri('/api/webauthn/register/start')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end