ory / hydra-client-ruby

Autogenerated hydra SDK.
Apache License 2.0
5 stars 2 forks source link

authorization_code_grant_access_token_lifespan cannot be nil #6

Open maricavor opened 4 months ago

maricavor commented 4 months ago

Preflight checklist

Ory Network Project

No response

Describe the bug

Please revert back custom attribute writer methods for OAuth2Client. If records already exist cannot update and recieve ArgumentError: authorization_code_grant_access_token_lifespan cannot be nil. Those attributes are optional and new implementation is wrong when they are nil:

def authorization_code_grant_access_token_lifespan=(authorization_code_grant_access_token_lifespan)
      if authorization_code_grant_access_token_lifespan.nil?
        fail ArgumentError, 'authorization_code_grant_access_token_lifespan cannot be nil'
      end

      pattern = Regexp.new(/^([0-9]+(ns|us|ms|s|m|h))*$/)
      if authorization_code_grant_access_token_lifespan !~ pattern
        fail ArgumentError, "invalid value for \"authorization_code_grant_access_token_lifespan\", must conform to the pattern #{pattern}."
      end

      @authorization_code_grant_access_token_lifespan = authorization_code_grant_access_token_lifespan
    end

The correct implementation from version 2.2.0:

    # Custom attribute writer method with validation
    # @param [Object] authorization_code_grant_access_token_lifespan Value to be assigned
    def authorization_code_grant_access_token_lifespan=(authorization_code_grant_access_token_lifespan)
      pattern = Regexp.new(/^([0-9]+(ns|us|ms|s|m|h))*$/)
      if !authorization_code_grant_access_token_lifespan.nil? && authorization_code_grant_access_token_lifespan !~ pattern
        fail ArgumentError, "invalid value for \"authorization_code_grant_access_token_lifespan\", must conform to the pattern #{pattern}."
      end

      @authorization_code_grant_access_token_lifespan = authorization_code_grant_access_token_lifespan
    end

Reproducing the bug

Make Api request set_o_auth2_client for an existing record

Relevant log output

No response

Relevant configuration

No response

Version

2.2.1

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Docker

Additional Context

No response

Schmitze333 commented 3 months ago

It's not only the authorization_code_grant_access_token_lifespan affected, but also all other lifespan attributes (authorization_code_grant_id_token_lifespan, authorization_code_grant_refresh_token_lifespan, client_credentials_grant_access_token_lifespan, ...).