Skip to content

Instantly share code, notes, and snippets.

View olivierbuffon's full-sized avatar
💎
Doing awesome stuff with Ruby on Rails

Olivier Buffon olivierbuffon

💎
Doing awesome stuff with Ruby on Rails
View GitHub Profile
@olivierbuffon
olivierbuffon / association.rb
Created October 18, 2023 18:35 — forked from itkrt2y/association.rb
Association dataloader with graphql-ruby
# official docs: https://graphql-ruby.org/dataloader/sources.html
# app/graphql/sources/association.rb
class Sources::Association < ::GraphQL::Dataloader::Source
def initialize(association_name, scope = nil)
@association_name = association_name
@scope = scope
end
def fetch(records)
@olivierbuffon
olivierbuffon / README.md
Created June 6, 2023 20:21 — forked from ingeniousgenius/README.md
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using: