Skip to content

Conversation

@Jbur43
Copy link

@Jbur43 Jbur43 commented Oct 7, 2025

No description provided.

@tomprats
Copy link
Member

tomprats commented Oct 8, 2025

Probably good to add .DS_Store to your global gitignore file ~/.gitignore


private

def authenticate_with_token
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to give a little more control to the application, maybe traitify-ruby only needs:

  • traitify.valid_jwt_token?(x)
  • traitify.jwt_public_keys=([x, y])

And then we wouldn't need to have the railties and actionpack dependencies. Then in our rails apps we'd pretty much just add:

# In existing Traitify initializer
Traitify.jwt_public_keys = [ENV["JWT_PUBLIC_KEY"], ENV["JWT_PUBLIC_KEY_LEGACY"]].select(&:present?)


# In a concern or controller, allowing us to accept multiple forms of auth and rendering app specific errors
def authenticate_with_jwt
  token = extract_token_from_header

   return render_unauthorized("Missing token") if token.nil?
   render_unauthorized("Invalid token") unless valid_token?(token)
end

@Jbur43 Jbur43 requested a review from tomprats November 4, 2025 22:30
Copy link
Member

@tomprats tomprats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method and tests both look good. I think there's just a bunch of leftover stuff from the original implementation

validate_claims(payload)
return true
rescue JWT::ExpiredSignature, JWT::DecodeError, JWT::VerificationError => e
Traitify.logger.warn("[JWT] #{e.class.name}: #{e.message}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just do logger or log directly here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these should be removed


SimpleCov.start :test_frameworks

module Rails
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still required?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file/folder can be deleted now

spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_runtime_dependency "activesupport", ">= 5.1", "< 8.x"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need the activesupport dependency for some previous things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants