fusionauth_client 1.36.0 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -37
- data/build.savant +1 -1
- data/examples/create_user.rb +35 -0
- data/examples/login.rb +24 -0
- data/fusionauth-ruby-client.iml +4 -4
- data/fusionauth_client.gemspec +1 -1
- data/lib/fusionauth/fusionauth_client.rb +59 -11
- metadata +4 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5eb61cb704a42c5bd5a998859c6ffb26b9b289c58c45c9b75efe733c665ebc8b
         | 
| 4 | 
            +
              data.tar.gz: 740ac46b4224832c35d25d4b17b5f1a85154db828e5fcec345cbd54c9b84fc0d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: caee0c1e79f338f05ec359edf332fc5432e29bf382e3a04c0130921e0c9785cf99f8d082affa9f49e00b4fff1904fbdf861b4f355c40db235e0b9539a9136459
         | 
| 7 | 
            +
              data.tar.gz: 9186f9f3784eca040d3da2e2a949fb424d89a7ba9da258c01f532aa9f1dea1ce268920788b8216cd9b1fe26f833ebd7fbfd9cccb1040741fa87826424ea89fac
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -20,44 +20,9 @@ Or install it yourself as: | |
| 20 20 |  | 
| 21 21 | 
             
            ## Usage
         | 
| 22 22 |  | 
| 23 | 
            -
            Once the gem is installed, you can call FusionAuth APIs | 
| 23 | 
            +
            Once the gem is installed, you can call FusionAuth APIs.
         | 
| 24 24 |  | 
| 25 | 
            -
             | 
| 26 | 
            -
            require 'fusionauth/fusionauth_client'
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            # Construct the FusionAuth Client
         | 
| 29 | 
            -
            client = FusionAuth::FusionAuthClient.new(
         | 
| 30 | 
            -
                '<YOUR_API_KEY>', 
         | 
| 31 | 
            -
                'http://localhost:9011'
         | 
| 32 | 
            -
            )
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            # Create a user + registration
         | 
| 35 | 
            -
            id = SecureRandom.uuid
         | 
| 36 | 
            -
            client.register(id, {
         | 
| 37 | 
            -
                :user => {
         | 
| 38 | 
            -
                    :firstName => 'Ruby',
         | 
| 39 | 
            -
                    :lastName => 'Client',
         | 
| 40 | 
            -
                    :email => 'ruby.client.test@fusionauth.io',
         | 
| 41 | 
            -
                    :password => 'password'
         | 
| 42 | 
            -
                },
         | 
| 43 | 
            -
                :registration => {
         | 
| 44 | 
            -
                    :applicationId => application_id,
         | 
| 45 | 
            -
                    :data => {
         | 
| 46 | 
            -
                        :foo => 'bar'
         | 
| 47 | 
            -
                    },
         | 
| 48 | 
            -
                    :preferredLanguages => %w(en fr),
         | 
| 49 | 
            -
                    :roles => %w(user)
         | 
| 50 | 
            -
                }
         | 
| 51 | 
            -
            })
         | 
| 52 | 
            -
             | 
| 53 | 
            -
            # Authenticate the user
         | 
| 54 | 
            -
            response = client.login({
         | 
| 55 | 
            -
                :loginId => 'ruby.client.test@fusionauth.io',
         | 
| 56 | 
            -
                :password => 'password',
         | 
| 57 | 
            -
                :applicationId => application_id
         | 
| 58 | 
            -
            })
         | 
| 59 | 
            -
            user = response.success.response.user
         | 
| 60 | 
            -
            ```
         | 
| 25 | 
            +
            See examples in the `examples` directory.
         | 
| 61 26 |  | 
| 62 27 | 
             
            ## Questions and support
         | 
| 63 28 |  | 
    
        data/build.savant
    CHANGED
    
    | @@ -16,7 +16,7 @@ | |
| 16 16 | 
             
            savantVersion = "1.0.0"
         | 
| 17 17 |  | 
| 18 18 | 
             
            pubVersion = ""
         | 
| 19 | 
            -
            project(group: "io.fusionauth", name: "fusionauth-ruby-client", version: "1. | 
| 19 | 
            +
            project(group: "io.fusionauth", name: "fusionauth-ruby-client", version: "1.37.0", licenses: ["ApacheV2_0"]) {
         | 
| 20 20 | 
             
              workflow {
         | 
| 21 21 | 
             
                fetch {
         | 
| 22 22 | 
             
                  cache()
         | 
| @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            require 'fusionauth/fusionauth_client'
         | 
| 2 | 
            +
            require 'securerandom'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            # Construct the FusionAuth Client
         | 
| 5 | 
            +
            client = FusionAuth::FusionAuthClient.new(
         | 
| 6 | 
            +
                'APIKEY', 
         | 
| 7 | 
            +
                'http://localhost:9011'
         | 
| 8 | 
            +
            )
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            application_id = '20ce6dac-b985-4c77-bb59-6369249f884b'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            # Create a user + registration
         | 
| 13 | 
            +
            id = SecureRandom.uuid
         | 
| 14 | 
            +
            response = client.register(id, {
         | 
| 15 | 
            +
                :user => {
         | 
| 16 | 
            +
                    :firstName => 'Ruby',
         | 
| 17 | 
            +
                    :lastName => 'Client',
         | 
| 18 | 
            +
                    :email => 'ruby.client.test@fusionauth.io',
         | 
| 19 | 
            +
                    :password => 'password'
         | 
| 20 | 
            +
                },
         | 
| 21 | 
            +
                :registration => {
         | 
| 22 | 
            +
                    :applicationId => application_id,
         | 
| 23 | 
            +
                    :data => {
         | 
| 24 | 
            +
                        :foo => 'bar'
         | 
| 25 | 
            +
                    },
         | 
| 26 | 
            +
                    :preferredLanguages => %w(en fr),
         | 
| 27 | 
            +
                    :roles => %w(user)
         | 
| 28 | 
            +
                }
         | 
| 29 | 
            +
            })
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            unless response.success_response
         | 
| 32 | 
            +
              print response.error_response
         | 
| 33 | 
            +
              exit
         | 
| 34 | 
            +
            end
         | 
| 35 | 
            +
             | 
    
        data/examples/login.rb
    ADDED
    
    | @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            require 'fusionauth/fusionauth_client'
         | 
| 2 | 
            +
            require 'securerandom'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            # Construct the FusionAuth Client
         | 
| 5 | 
            +
            client = FusionAuth::FusionAuthClient.new(
         | 
| 6 | 
            +
                'APIKEY', 
         | 
| 7 | 
            +
                'http://localhost:9011'
         | 
| 8 | 
            +
            )
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            application_id = '20ce6dac-b985-4c77-bb59-6369249f884b'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            # Authenticate a user
         | 
| 13 | 
            +
            response = client.login({
         | 
| 14 | 
            +
                :loginId => 'ruby.client.test@fusionauth.io',
         | 
| 15 | 
            +
                :password => 'password',
         | 
| 16 | 
            +
                :applicationId => application_id
         | 
| 17 | 
            +
            })
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            if response.success_response
         | 
| 20 | 
            +
              user = response.success_response.user
         | 
| 21 | 
            +
              print user.id
         | 
| 22 | 
            +
            else 
         | 
| 23 | 
            +
              print response.error_response
         | 
| 24 | 
            +
            end
         | 
    
        data/fusionauth-ruby-client.iml
    CHANGED
    
    | @@ -16,16 +16,16 @@ | |
| 16 16 | 
             
                <option name="myRootTask">
         | 
| 17 17 | 
             
                  <RakeTaskImpl id="rake">
         | 
| 18 18 | 
             
                    <subtasks>
         | 
| 19 | 
            -
                      <RakeTaskImpl description="Build fusionauth_client-1. | 
| 19 | 
            +
                      <RakeTaskImpl description="Build fusionauth_client-1.37.0.gem into the pkg directory" fullCommand="build" id="build" />
         | 
| 20 20 | 
             
                      <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
         | 
| 21 21 | 
             
                      <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
         | 
| 22 | 
            -
                      <RakeTaskImpl description="Build and install fusionauth_client-1. | 
| 22 | 
            +
                      <RakeTaskImpl description="Build and install fusionauth_client-1.37.0.gem into system gems" fullCommand="install" id="install" />
         | 
| 23 23 | 
             
                      <RakeTaskImpl id="install">
         | 
| 24 24 | 
             
                        <subtasks>
         | 
| 25 | 
            -
                          <RakeTaskImpl description="Build and install fusionauth_client-1. | 
| 25 | 
            +
                          <RakeTaskImpl description="Build and install fusionauth_client-1.37.0.gem into system gems without network access" fullCommand="install:local" id="local" />
         | 
| 26 26 | 
             
                        </subtasks>
         | 
| 27 27 | 
             
                      </RakeTaskImpl>
         | 
| 28 | 
            -
                      <RakeTaskImpl description="Create tag v1. | 
| 28 | 
            +
                      <RakeTaskImpl description="Create tag v1.37.0 and build and push fusionauth_client-1.37.0.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
         | 
| 29 29 | 
             
                      <RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
         | 
| 30 30 | 
             
                      <RakeTaskImpl description="" fullCommand="default" id="default" />
         | 
| 31 31 | 
             
                      <RakeTaskImpl description="" fullCommand="release" id="release" />
         | 
    
        data/fusionauth_client.gemspec
    CHANGED
    
    | @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
| 4 4 |  | 
| 5 5 | 
             
            Gem::Specification.new do |spec|
         | 
| 6 6 | 
             
              spec.name          = 'fusionauth_client'
         | 
| 7 | 
            -
              spec.version       = '1. | 
| 7 | 
            +
              spec.version       = '1.37.0'
         | 
| 8 8 | 
             
              spec.authors       = ['Brian Pontarelli', 'Daniel DeGroff']
         | 
| 9 9 | 
             
              spec.email         = %w(brian@fusionauth.io daniel@fusionauth.io)
         | 
| 10 10 |  | 
| @@ -2,7 +2,7 @@ require 'ostruct' | |
| 2 2 | 
             
            require 'fusionauth/rest_client'
         | 
| 3 3 |  | 
| 4 4 | 
             
            #
         | 
| 5 | 
            -
            # Copyright (c) 2018- | 
| 5 | 
            +
            # Copyright (c) 2018-2022, FusionAuth, All Rights Reserved
         | 
| 6 6 | 
             
            #
         | 
| 7 7 | 
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 8 8 | 
             
            # you may not use this file except in compliance with the License.
         | 
| @@ -130,9 +130,9 @@ module FusionAuth | |
| 130 130 | 
             
                #
         | 
| 131 131 | 
             
                # Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
         | 
| 132 132 | 
             
                # When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
         | 
| 133 | 
            -
                # your password, you must obtain a  | 
| 133 | 
            +
                # your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
         | 
| 134 134 | 
             
                # 
         | 
| 135 | 
            -
                # An HTTP status code of  | 
| 135 | 
            +
                # An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
         | 
| 136 136 | 
             
                #
         | 
| 137 137 | 
             
                # @param change_password_id [string] The change password Id used to find the user. This value is generated by FusionAuth once the change password workflow has been initiated.
         | 
| 138 138 | 
             
                # @return [FusionAuth::ClientResponse] The ClientResponse object.
         | 
| @@ -146,9 +146,9 @@ module FusionAuth | |
| 146 146 | 
             
                #
         | 
| 147 147 | 
             
                # Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
         | 
| 148 148 | 
             
                # When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
         | 
| 149 | 
            -
                # your password, you must obtain a  | 
| 149 | 
            +
                # your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
         | 
| 150 150 | 
             
                # 
         | 
| 151 | 
            -
                # An HTTP status code of  | 
| 151 | 
            +
                # An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
         | 
| 152 152 | 
             
                #
         | 
| 153 153 | 
             
                # @param encoded_jwt [string] The encoded JWT (access token).
         | 
| 154 154 | 
             
                # @return [FusionAuth::ClientResponse] The ClientResponse object.
         | 
| @@ -162,9 +162,9 @@ module FusionAuth | |
| 162 162 | 
             
                #
         | 
| 163 163 | 
             
                # Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
         | 
| 164 164 | 
             
                # When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
         | 
| 165 | 
            -
                # your password, you must obtain a  | 
| 165 | 
            +
                # your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication.
         | 
| 166 166 | 
             
                # 
         | 
| 167 | 
            -
                # An HTTP status code of  | 
| 167 | 
            +
                # An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
         | 
| 168 168 | 
             
                #
         | 
| 169 169 | 
             
                # @param login_id [string] The loginId of the User that you intend to change the password for.
         | 
| 170 170 | 
             
                # @return [FusionAuth::ClientResponse] The ClientResponse object.
         | 
| @@ -1511,6 +1511,21 @@ module FusionAuth | |
| 1511 1511 | 
             
                      .go()
         | 
| 1512 1512 | 
             
                end
         | 
| 1513 1513 |  | 
| 1514 | 
            +
                #
         | 
| 1515 | 
            +
                # Sends a ping to FusionAuth indicating that the user was automatically logged into an application. When using
         | 
| 1516 | 
            +
                # FusionAuth's SSO or your own, you should call this if the user is already logged in centrally, but accesses an
         | 
| 1517 | 
            +
                # application where they no longer have a session. This helps correctly track login counts, times and helps with
         | 
| 1518 | 
            +
                # reporting.
         | 
| 1519 | 
            +
                #
         | 
| 1520 | 
            +
                # @param request [OpenStruct, Hash] The login request that contains the user credentials used to log them in.
         | 
| 1521 | 
            +
                # @return [FusionAuth::ClientResponse] The ClientResponse object.
         | 
| 1522 | 
            +
                def login_ping_with_request(request)
         | 
| 1523 | 
            +
                  start.uri('/api/login')
         | 
| 1524 | 
            +
                      .body_handler(FusionAuth::JSONBodyHandler.new(request))
         | 
| 1525 | 
            +
                      .put()
         | 
| 1526 | 
            +
                      .go()
         | 
| 1527 | 
            +
                end
         | 
| 1528 | 
            +
             | 
| 1514 1529 | 
             
                #
         | 
| 1515 1530 | 
             
                # The Logout API is intended to be used to remove the refresh token and access token cookies if they exist on the
         | 
| 1516 1531 | 
             
                # client and revoke the refresh token stored. This API does nothing if the request does not contain an access
         | 
| @@ -2780,13 +2795,13 @@ module FusionAuth | |
| 2780 2795 | 
             
                end
         | 
| 2781 2796 |  | 
| 2782 2797 | 
             
                #
         | 
| 2783 | 
            -
                # Retrieves a single refresh token by unique Id. This is not the same thing as the string value of the refresh token | 
| 2798 | 
            +
                # Retrieves a single refresh token by unique Id. This is not the same thing as the string value of the refresh token. If you have that, you already have what you need.
         | 
| 2784 2799 | 
             
                #
         | 
| 2785 | 
            -
                # @param  | 
| 2800 | 
            +
                # @param token_id [string] The Id of the token.
         | 
| 2786 2801 | 
             
                # @return [FusionAuth::ClientResponse] The ClientResponse object.
         | 
| 2787 | 
            -
                def retrieve_refresh_token_by_id( | 
| 2802 | 
            +
                def retrieve_refresh_token_by_id(token_id)
         | 
| 2788 2803 | 
             
                  start.uri('/api/jwt/refresh')
         | 
| 2789 | 
            -
                      .url_segment( | 
| 2804 | 
            +
                      .url_segment(token_id)
         | 
| 2790 2805 | 
             
                      .get()
         | 
| 2791 2806 | 
             
                      .go()
         | 
| 2792 2807 | 
             
                end
         | 
| @@ -2922,6 +2937,25 @@ module FusionAuth | |
| 2922 2937 | 
             
                      .go()
         | 
| 2923 2938 | 
             
                end
         | 
| 2924 2939 |  | 
| 2940 | 
            +
                #
         | 
| 2941 | 
            +
                # Retrieve a user's two-factor status.
         | 
| 2942 | 
            +
                # 
         | 
| 2943 | 
            +
                # This can be used to see if a user will need to complete a two-factor challenge to complete a login,
         | 
| 2944 | 
            +
                # and optionally identify the state of the two-factor trust across various applications.
         | 
| 2945 | 
            +
                #
         | 
| 2946 | 
            +
                # @param user_id [string] The user Id to retrieve the Two-Factor status.
         | 
| 2947 | 
            +
                # @param application_id [string] The optional applicationId to verify.
         | 
| 2948 | 
            +
                # @param two_factor_trust_id [string] The optional two-factor trust Id to verify.
         | 
| 2949 | 
            +
                # @return [FusionAuth::ClientResponse] The ClientResponse object.
         | 
| 2950 | 
            +
                def retrieve_two_factor_status(user_id, application_id, two_factor_trust_id)
         | 
| 2951 | 
            +
                  start.uri('/api/two-factor/status')
         | 
| 2952 | 
            +
                      .url_parameter('userId', user_id)
         | 
| 2953 | 
            +
                      .url_parameter('applicationId', application_id)
         | 
| 2954 | 
            +
                      .url_segment(two_factor_trust_id)
         | 
| 2955 | 
            +
                      .get()
         | 
| 2956 | 
            +
                      .go()
         | 
| 2957 | 
            +
                end
         | 
| 2958 | 
            +
             | 
| 2925 2959 | 
             
                #
         | 
| 2926 2960 | 
             
                # Retrieves the user for the given Id.
         | 
| 2927 2961 | 
             
                #
         | 
| @@ -4151,6 +4185,20 @@ module FusionAuth | |
| 4151 4185 | 
             
                      .go()
         | 
| 4152 4186 | 
             
                end
         | 
| 4153 4187 |  | 
| 4188 | 
            +
                #
         | 
| 4189 | 
            +
                # Administratively verify a user's email address. Use this method to bypass email verification for the user.
         | 
| 4190 | 
            +
                # 
         | 
| 4191 | 
            +
                # The request body will contain the userId to be verified. An API key is required when sending the userId in the request body.
         | 
| 4192 | 
            +
                #
         | 
| 4193 | 
            +
                # @param request [OpenStruct, Hash] The request that contains the userId to verify.
         | 
| 4194 | 
            +
                # @return [FusionAuth::ClientResponse] The ClientResponse object.
         | 
| 4195 | 
            +
                def verify_email_address_by_user_id(request)
         | 
| 4196 | 
            +
                  start.uri('/api/user/verify-email')
         | 
| 4197 | 
            +
                      .body_handler(FusionAuth::JSONBodyHandler.new(request))
         | 
| 4198 | 
            +
                      .post()
         | 
| 4199 | 
            +
                      .go()
         | 
| 4200 | 
            +
                end
         | 
| 4201 | 
            +
             | 
| 4154 4202 | 
             
                #
         | 
| 4155 4203 | 
             
                # Confirms an application registration. The Id given is usually from an email sent to the user.
         | 
| 4156 4204 | 
             
                #
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fusionauth_client
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.37.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Brian Pontarelli
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: exe
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2022- | 
| 12 | 
            +
            date: 2022-08-11 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies: []
         | 
| 14 14 | 
             
            description: This library contains the Ruby client library that helps you connect
         | 
| 15 15 | 
             
              your application to FusionAuth.
         | 
| @@ -28,6 +28,8 @@ files: | |
| 28 28 | 
             
            - README.md
         | 
| 29 29 | 
             
            - Rakefile
         | 
| 30 30 | 
             
            - build.savant
         | 
| 31 | 
            +
            - examples/create_user.rb
         | 
| 32 | 
            +
            - examples/login.rb
         | 
| 31 33 | 
             
            - fusionauth-ruby-client.iml
         | 
| 32 34 | 
             
            - fusionauth_client.gemspec
         | 
| 33 35 | 
             
            - lib/fusionauth/fusionauth_client.rb
         |