repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance.rb | lib/clearance.rb | require "clearance/configuration"
require "clearance/sign_in_guard"
require "clearance/session"
require "clearance/rack_session"
require "clearance/back_door"
require "clearance/controller"
require "clearance/user"
require "clearance/password_strategies"
require "clearance/constraints"
require "clearance/engine"
modul... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/generators/clearance/routes/routes_generator.rb | lib/generators/clearance/routes/routes_generator.rb | require "rails/generators/base"
module Clearance
module Generators
class RoutesGenerator < Rails::Generators::Base
source_root File.expand_path("../templates", __FILE__)
def inject_clearance_routes_into_application_routes
route(clearance_routes)
end
def disable_clearance_interna... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/generators/clearance/routes/templates/routes.rb | lib/generators/clearance/routes/templates/routes.rb | resources :passwords, controller: "clearance/passwords", only: [:create, :new]
resource :session, controller: "clearance/sessions", only: [:create]
resources :users, controller: "clearance/users", only: [:create] do
resource :password,
controller: "clearance/passwords",
only: [:edit, :update]
end
get "/sign... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/generators/clearance/views/views_generator.rb | lib/generators/clearance/views/views_generator.rb | require "rails/generators/base"
module Clearance
module Generators
class ViewsGenerator < Rails::Generators::Base
source_root File.expand_path("../../../../..", __FILE__)
def create_views
views.each do |view|
copy_file view
end
end
def create_locales
lo... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/generators/clearance/specs/specs_generator.rb | lib/generators/clearance/specs/specs_generator.rb | require "rails/generators/base"
require "rspec/rails/version"
module Clearance
module Generators
class SpecsGenerator < Rails::Generators::Base
source_root File.expand_path("../templates", __FILE__)
def create_specs
@helper_file = rspec_helper_file
directory ".", "spec"
end
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/generators/clearance/specs/templates/support/clearance.rb | lib/generators/clearance/specs/templates/support/clearance.rb | require "clearance/rspec"
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb | lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb | module Features
module ClearanceHelpers
def reset_password_for(email)
visit new_password_path
fill_in "password_email", with: email
click_button I18n.t("helpers.submit.password.submit")
end
def sign_in
password = "password"
user = FactoryBot.create(:user, password: password)... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/generators/clearance/specs/templates/factories/clearance.rb | lib/generators/clearance/specs/templates/factories/clearance.rb | FactoryBot.define do
sequence :email do |n|
"user#{n}@example.com"
end
factory :user do
email
password { "password" }
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/generators/clearance/install/install_generator.rb | lib/generators/clearance/install/install_generator.rb | require "rails/generators/base"
require "rails/generators/active_record"
module Clearance
module Generators
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path("../templates", __FILE__)
def create_clearance_initializer
cop... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/generators/clearance/install/templates/clearance.rb | lib/generators/clearance/install/templates/clearance.rb | Clearance.configure do |config|
config.mailer_sender = "reply@example.com"
config.rotate_csrf_on_sign_in = true
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/authentication.rb | lib/clearance/authentication.rb | module Clearance
module Authentication
extend ActiveSupport::Concern
included do
if respond_to?(:helper_method)
helper_method :current_user, :signed_in?, :signed_out?
end
private(
:authenticate,
:current_user,
:handle_unverified_request,
:sign_in,
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/sign_in_guard.rb | lib/clearance/sign_in_guard.rb | require "clearance/session_status"
module Clearance
# The base class for {DefaultSignInGuard} and all custom sign in guards.
#
# Sign in guards provide you with fine-grained control over the process of
# signing in a user. Each guard is run in order and can do one of the
# following:
#
# * Fail the sign ... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/session.rb | lib/clearance/session.rb | require "clearance/default_sign_in_guard"
module Clearance
# Represents a clearance session, ultimately persisted in
# `request.env[:clearance]` by {RackSession}.
class Session
# @param env The current rack environment
def initialize(env)
@env = env
@current_user = nil
@cookies = nil
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/version.rb | lib/clearance/version.rb | module Clearance
VERSION = "2.11.0".freeze
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/default_sign_in_guard.rb | lib/clearance/default_sign_in_guard.rb | module Clearance
# Runs as the base {SignInGuard} for all requests, regardless of configured
# {Configuration#sign_in_guards}.
class DefaultSignInGuard < SignInGuard
# Runs the default sign in guard.
#
# If there is a value set in the clearance session object, then the guard
# returns {SuccessStat... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/test_unit.rb | lib/clearance/test_unit.rb | require "clearance/testing/deny_access_matcher"
require "clearance/testing/controller_helpers"
ActionController::TestCase.extend Clearance::Testing::Matchers
class ActionController::TestCase
include Clearance::Testing::ControllerHelpers
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/constraints.rb | lib/clearance/constraints.rb | require "clearance/constraints/signed_in"
require "clearance/constraints/signed_out"
module Clearance
# Clearance provides Rails routing constraints that can control access and the
# visibility of routes at the routing layer. The {Constraints::SignedIn}
# constraint can be used to make routes visible only to sig... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/back_door.rb | lib/clearance/back_door.rb | module Clearance
# Middleware which allows signing in by passing as=USER_ID in a query
# parameter. If `User#to_param` is overriden you may pass a block to
# override the default user lookup behaviour
#
# Designed to eliminate time in integration tests wasted by visiting and
# submitting the sign in form.
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/configuration.rb | lib/clearance/configuration.rb | module Clearance
class Configuration
# Controls whether the sign up route is enabled.
# Defaults to `true`. Set to `false` to disable user creation routes.
# The setting is ignored if routes are disabled.
# @param [Boolean] value
# @return [Boolean]
attr_writer :allow_sign_up
# Controls w... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/controller.rb | lib/clearance/controller.rb | require "clearance/authentication"
require "clearance/authorization"
module Clearance
# Adds clearance controller helpers to the controller it is mixed into.
#
# This exposes clearance controller and helper methods such as `current_user`.
# See {Authentication} and {Authorization} documentation for complete
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/rack_session.rb | lib/clearance/rack_session.rb | module Clearance
# Rack middleware that manages the Clearance {Session}. This middleware is
# automatically mounted by the Clearance {Engine}.
#
# * maintains the session cookie specified by your {Configuration}.
# * exposes previously cookied sessions to Clearance and your app at
# `request.env[:clearanc... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/password_strategies.rb | lib/clearance/password_strategies.rb | module Clearance
# Control how users are authenticated and how passwords are stored.
#
# The default password strategy is {Clearance::PasswordStrategies::BCrypt},
# but this can be overridden in {Clearance::Configuration}.
#
# You can supply your own password strategy by implementing a module that
# respo... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/rspec.rb | lib/clearance/rspec.rb | require "rspec/rails"
require "clearance/testing/deny_access_matcher"
require "clearance/testing/controller_helpers"
require "clearance/testing/view_helpers"
RSpec.configure do |config|
config.include Clearance::Testing::Matchers, type: :controller
config.include Clearance::Testing::ControllerHelpers, type: :contr... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/token.rb | lib/clearance/token.rb | module Clearance
# Random token used for password reset and remember tokens.
# Clearance tokens are also public API and are intended to be used anywhere
# you need a random token to correspond to a given user (e.g. you added an
# email confirmation token).
class Token
# Generate a new random, 20 byte hex ... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/authorization.rb | lib/clearance/authorization.rb | module Clearance
module Authorization
extend ActiveSupport::Concern
included do
private :deny_access, :require_login
end
# Use as a `before_action` to require a user be signed in to proceed.
# {Authentication#signed_in?} is used to determine if there is a signed in
# user or not.
#... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/engine.rb | lib/clearance/engine.rb | require "rails/engine"
module Clearance
# Makes Clearance behavior available to Rails apps on initialization. By using
# a Rails Engine rather than a Railtie, Clearance can automatically expose its
# own routes and views to the hosting application.
#
# Requiring `clearance` (likely by having it in your `Gemf... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/session_status.rb | lib/clearance/session_status.rb | module Clearance
# Indicates a user was successfully signed in, passing all {SignInGuard}s.
class SuccessStatus
# Is true, indicating that the sign in was successful.
def success?
true
end
end
# Indicates a failure in the {SignInGuard} stack which prevented successful
# sign in.
class Fai... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/user.rb | lib/clearance/user.rb | require "digest/sha1"
require "active_model"
require "email_validator"
require "clearance/token"
module Clearance
# Required to be included in your configued user class, which is `User` by
# default, but can be changed with {Configuration#user_model=}.
#
# class User
# include Clearance::User
#
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/password_strategies/argon2.rb | lib/clearance/password_strategies/argon2.rb | module Clearance
module PasswordStrategies
# Uses Argon2 to authenticate users and store encrypted passwords.
module Argon2
require "argon2"
def authenticated?(password)
if encrypted_password.present?
::Argon2::Password.verify_password(password, encrypted_password)
end
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/password_strategies/bcrypt.rb | lib/clearance/password_strategies/bcrypt.rb | module Clearance
module PasswordStrategies
# Uses BCrypt to authenticate users and store encrypted passwords.
#
# BCrypt has a `cost` argument which determines how computationally
# expensive the hash is to calculate. The higher the cost, the harder it is
# for attackers to crack passwords even if... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/constraints/signed_in.rb | lib/clearance/constraints/signed_in.rb | module Clearance
module Constraints
# Can be applied to make a set of routes visible only to users that are
# signed in.
#
# # config/routes.rb
# constraints Clearance::Constraints::SignedIn.new do
# resources :posts
# end
#
# In the example above, requests to `/p... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/constraints/signed_out.rb | lib/clearance/constraints/signed_out.rb | module Clearance
module Constraints
# Can be applied to make a set of routes visible only to users that are
# signed out.
#
# # config/routes.rb
# constraints Clearance::Constraints::SignedOut.new do
# resources :registrations, only: [:new, :create]
# end
#
# In t... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/testing/deny_access_matcher.rb | lib/clearance/testing/deny_access_matcher.rb | module Clearance
module Testing
# Provides matchers to be used in your controller specs.
# These are typically exposed to your controller specs by
# requiring `clearance/rspec` or `clearance/test_unit` as
# appropriate in your `rails_helper.rb` or `test_helper.rb`
# files.
module Matchers
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/testing/view_helpers.rb | lib/clearance/testing/view_helpers.rb | module Clearance
module Testing
# Provides helpers to your view and helper specs.
# Using these helpers makes `current_user`, `signed_in?` and `signed_out?`
# behave properly in view and helper specs.
module ViewHelpers
# Sets current_user on the view under test to a new instance of your user
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/lib/clearance/testing/controller_helpers.rb | lib/clearance/testing/controller_helpers.rb | module Clearance
module Testing
# Provides helpers to your controller specs.
# These are typically used in tests by requiring `clearance/rspec` or
# `clearance/test_unit` as appropriate in your `rails_helper.rb` or
# `test_helper.rb` files.
module ControllerHelpers
# @api private
def s... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/config/routes.rb | config/routes.rb | if Clearance.configuration.routes_enabled?
Rails.application.routes.draw do
resources :passwords,
controller: "clearance/passwords",
only: [:create, :new]
resource :session,
controller: "clearance/sessions",
only: [:create]
resources :users,
controller: "clearance/users",
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/bin/console.rb | bin/console.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require 'jwt'
require 'irb'
IRB.start(__FILE__)
| ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/bin/smoke.rb | bin/smoke.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'jwt'
puts "Running simple encode/decode test for #{JWT.gem_version}"
secret = 'secretkeyforsigning'
token = JWT.encode({ con: 'tent' }, secret, 'HS256')
JWT.decode(token, secret, true, algorithm: 'HS256')
| ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
require 'rspec'
require 'simplecov'
require 'jwt'
require_relative 'spec_support/test_keys'
require_relative 'spec_support/token'
puts "OpenSSL::VERSION: #{OpenSSL::VERSION}"
puts "OpenSSL::OPENSSL_VERSION: #{OpenSSL::OPENSSL_VERSION}"
puts "OpenSSL::OPENSSL_LIBRARY_VERSION: #{OpenSSL::... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/integration/readme_examples_spec.rb | spec/integration/readme_examples_spec.rb | # frozen_string_literal: true
require 'logger'
RSpec.describe 'README.md code test' do
context 'algorithm usage' do
let(:payload) { { data: 'test' } }
it 'NONE' do
token = JWT.encode payload, nil, 'none'
decoded_token = JWT.decode token, nil, false
expect(token).to eq 'eyJhbGciOiJub25lIn... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/spec_support/test_keys.rb | spec/spec_support/test_keys.rb | # frozen_string_literal: true
module SpecSupport
module TestKeys
KEY_FIXTURE_PATH = File.join(__dir__, '..', 'fixtures', 'keys')
def test_pkey(key)
TestKeys.keys[key] ||= read_pkey(key)
end
def read_pkey(key)
OpenSSL::PKey.read(File.read(File.join(KEY_FIXTURE_PATH, key)))
end
d... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/spec_support/token.rb | spec/spec_support/token.rb | # frozen_string_literal: true
module SpecSupport
Token = Struct.new(:payload, :header, keyword_init: true)
end
| ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/encoded_token_spec.rb | spec/jwt/encoded_token_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::EncodedToken do
let(:payload) { { 'pay' => 'load' } }
let(:header) { {} }
let(:encoded_token) { JWT::Token.new(payload: payload, header: header).tap { |t| t.sign!(algorithm: 'HS256', key: 'secret') }.jwt }
let(:detached_payload_token) do
JWT::Token.new(payl... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/version_spec.rb | spec/jwt/version_spec.rb | # frozen_string_literal: true
RSpec.describe JWT do
describe '.gem_version' do
it 'returns the gem version' do
expect(described_class.gem_version).to eq(Gem::Version.new(JWT::VERSION::STRING))
end
end
describe 'VERSION constants' do
it 'has a MAJOR version' do
expect(JWT::VERSION::MAJOR).... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwa_spec.rb | spec/jwt/jwa_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWA do
describe '.resolve_and_sort' do
let(:subject) { described_class.resolve_and_sort(algorithms: algorithms, preferred_algorithm: preferred_algorithm).map(&:alg) }
context 'when algorithms have the preferred last' do
let(:algorithms) { %w[HS256 HS51... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwt_spec.rb | spec/jwt/jwt_spec.rb | # frozen_string_literal: true
RSpec.describe JWT do
let(:payload) { { 'user_id' => 'some@user.tld' } }
let(:data) do
{
:empty_token => 'e30K.e30K.e30K',
:empty_token_2_segment => 'e30K.e30K.',
:invalid_header_token => 'W10.e30K.e30K',
:secret => 'My$ecretK3y',
:rsa_private => tes... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | true |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/x5c_key_finder_spec.rb | spec/jwt/x5c_key_finder_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::X5cKeyFinder do
let(:root_key) { test_pkey('rsa-2048-private.pem') }
let(:root_dn) { OpenSSL::X509::Name.parse('/DC=org/DC=fake-ca/CN=Fake CA') }
let(:root_certificate) { generate_root_cert(root_dn, root_key) }
let(:leaf_key) { generate_key }
let(:leaf_dn) { ... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/token_spec.rb | spec/jwt/token_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Token do
let(:payload) { { 'pay' => 'load' } }
let(:header) { {} }
subject(:token) { described_class.new(payload: payload, header: header) }
describe '#sign!' do
it 'signs the token' do
token.sign!(algorithm: 'HS256', key: 'secret')
expect(JW... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/configuration_spec.rb | spec/jwt/configuration_spec.rb | # frozen_string_literal: true
RSpec.describe JWT do
describe 'JWT.configure' do
it 'yields the configuration' do
expect { |b| described_class.configure(&b) }.to yield_with_args(described_class.configuration)
end
it 'allows configuration to be changed via the block' do
expect(described_class.... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/concurrent_encode_decode_spec.rb | spec/jwt/concurrent_encode_decode_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWA::Ecdsa do
context 'used across threads for encoding and decoding' do
it 'successfully encodes, decodes, and verifies' do
threads = 10.times.map do
Thread.new do
public_key_pem = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0D... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwk_spec.rb | spec/jwt/jwk_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWK do
let(:rsa_key) { test_pkey('rsa-2048-private.pem') }
let(:ec_key) { test_pkey('ec256k-private.pem') }
describe '.import' do
let(:keypair) { rsa_key.public_key }
let(:exported_key) { described_class.new(keypair).export }
let(:params) { exported_... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims_spec.rb | spec/jwt/claims_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims do
let(:payload) { { 'pay' => 'load' } }
describe '.verify_payload!' do
context 'when required_claims is passed' do
it 'raises error' do
expect { described_class.verify_payload!(payload, required: ['exp']) }.to raise_error(JWT::MissingRequi... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwk/ec_spec.rb | spec/jwt/jwk/ec_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWK::EC do
let(:ec_key) { test_pkey('ec384-private.pem') }
describe '.new' do
subject { described_class.new(keypair) }
context 'when a keypair with both keys given' do
let(:keypair) { ec_key }
it 'creates an instance of the class' do
e... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwk/decode_with_jwk_spec.rb | spec/jwt/jwk/decode_with_jwk_spec.rb | # frozen_string_literal: true
RSpec.describe JWT do
describe '.decode for JWK usecase' do
let(:keypair) { test_pkey('rsa-2048-private.pem') }
let(:jwk) { JWT::JWK.new(keypair) }
let(:valid_key) { jwk.export }
let(:public_jwks) { { keys: [valid_key, { kid: 'not_the_correct_one', kt... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwk/hmac_spec.rb | spec/jwt/jwk/hmac_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWK::HMAC do
let(:hmac_key) { 'secret-key' }
let(:key) { hmac_key }
subject(:jwk) { described_class.new(key) }
describe '.new' do
context 'when a secret key given' do
it 'creates an instance of the class' do
expect(jwk).to be_a described_clas... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwk/set_spec.rb | spec/jwt/jwk/set_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWK::Set do
describe '.new' do
it 'can create an empty set' do
expect(described_class.new.keys).to eql([])
end
context 'can create a set' do
it 'from a JWK' do
jwk = JWT::JWK.new 'testkey'
expect(described_class.new(jwk).keys)... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwk/thumbprint_spec.rb | spec/jwt/jwk/thumbprint_spec.rb | # frozen_string_literal: true
describe JWT::JWK::Thumbprint do
describe '#to_s' do
let(:jwk_json) { nil }
let(:jwk) { JWT::JWK.import(JSON.parse(jwk_json)) }
subject(:thumbprint) { described_class.new(jwk).to_s }
context 'when example from RFC is given' do
let(:jwk_json) do
'
... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwk/rsa_spec.rb | spec/jwt/jwk/rsa_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWK::RSA do
let(:rsa_key) { OpenSSL::PKey::RSA.new(2048) }
describe '.new' do
subject { described_class.new(keypair) }
context 'when a keypair with both keys given' do
let(:keypair) { rsa_key }
it 'creates an instance of the class' do
... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/configuration/jwk_configuration_spec.rb | spec/jwt/configuration/jwk_configuration_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Configuration::JwkConfiguration do
describe '.kid_generator_type=' do
context 'when invalid value is passed' do
it 'raises ArgumentError' do
expect { subject.kid_generator_type = :foo }.to raise_error(ArgumentError, 'foo is not a valid kid generator... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwa/ps_spec.rb | spec/jwt/jwa/ps_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWA::Ps do
let(:rsa_key) { test_pkey('rsa-2048-private.pem') }
let(:data) { 'test data' }
let(:ps256_instance) { described_class.new('PS256') }
let(:ps384_instance) { described_class.new('PS384') }
let(:ps512_instance) { described_class.new('PS512') }
befo... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwa/ecdsa_spec.rb | spec/jwt/jwa/ecdsa_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWA::Ecdsa do
describe '.curve_by_name' do
subject { described_class.curve_by_name(curve_name) }
context 'when secp256r1 is given' do
let(:curve_name) { 'secp256r1' }
it { is_expected.to eq(algorithm: 'ES256', digest: 'sha256') }
end
con... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwa/unsupported_spec.rb | spec/jwt/jwa/unsupported_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWA::Unsupported do
describe '.sign' do
it 'raises an error for unsupported signing method' do
expect { described_class.sign('data', 'key') }.to raise_error(JWT::EncodeError, 'Unsupported signing method')
end
end
describe '.verify' do
it 'raise... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwa/hmac_spec.rb | spec/jwt/jwa/hmac_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWA::Hmac do
let(:instance) { described_class.new('HS256', OpenSSL::Digest::SHA256) }
let(:valid_signature) { [60, 56, 87, 72, 185, 194, 150, 13, 18, 148, 76, 245, 94, 91, 201, 64, 111, 91, 167, 156, 43, 148, 41, 113, 168, 156, 137, 12, 11, 31, 58, 97].pack('C*') }... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwa/none_spec.rb | spec/jwt/jwa/none_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWA::None do
subject { described_class.new }
describe '#sign' do
it 'returns an empty string' do
expect(subject.sign('data', 'key')).to eq('')
end
end
describe '#verify' do
it 'returns true' do
expect(subject.verify('data', 'signature'... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/jwa/rsa_spec.rb | spec/jwt/jwa/rsa_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::JWA::Rsa do
let(:rsa_key) { test_pkey('rsa-2048-private.pem') }
let(:data) { 'test data' }
let(:rsa_instance) { described_class.new('RS256') }
describe '#initialize' do
it 'initializes with the correct algorithm and digest' do
expect(rsa_instance.ins... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/expiration_spec.rb | spec/jwt/claims/expiration_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::Expiration do
let(:payload) { { 'exp' => (Time.now.to_i + 5) } }
let(:leeway) { 0 }
subject(:verify!) { described_class.new(leeway: leeway).verify!(context: SpecSupport::Token.new(payload: payload)) }
context 'when token is expired' do
let(:payloa... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/crit_spec.rb | spec/jwt/claims/crit_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::Crit do
subject(:verify!) { described_class.new(expected_crits: expected_crits).verify!(context: SpecSupport::Token.new(header: header)) }
let(:expected_crits) { [] }
let(:header) { {} }
context 'when header is missing' do
it 'raises JWT::InvalidCr... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/audience_spec.rb | spec/jwt/claims/audience_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::Audience do
let(:payload) { { 'nbf' => (Time.now.to_i + 5) } }
describe '#verify!' do
let(:scalar_aud) { 'ruby-jwt-aud' }
let(:array_aud) { %w[ruby-jwt-aud test-aud ruby-ruby-ruby] }
subject(:verify!) { described_class.new(expected_audience: e... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/not_before_spec.rb | spec/jwt/claims/not_before_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::NotBefore do
let(:payload) { { 'nbf' => (Time.now.to_i + 5) } }
describe '#verify!' do
context 'when nbf is in the future' do
it 'raises JWT::ImmatureSignature' do
expect { described_class.new(leeway: 0).verify!(context: SpecSupport::Toke... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/numeric_spec.rb | spec/jwt/claims/numeric_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::Numeric do
shared_examples_for 'a NumericDate claim' do |claim|
context "when #{claim} payload is an integer" do
let(:claims) { { claim => 12_345 } }
it 'does not raise error' do
expect { subject }.not_to raise_error
end
... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/required_spec.rb | spec/jwt/claims/required_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::Required do
let(:payload) { { 'data' => 'value' } }
subject(:verify!) { described_class.new(required_claims: required_claims).verify!(context: SpecSupport::Token.new(payload: payload)) }
context 'when payload is missing the required claim' do
let(:r... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/issued_at_spec.rb | spec/jwt/claims/issued_at_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::IssuedAt do
let(:payload) { { 'iat' => Time.now.to_f } }
subject(:verify!) { described_class.new.verify!(context: SpecSupport::Token.new(payload: payload)) }
context 'when iat is now' do
it 'passes validation' do
verify!
end
end
conte... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/jwt_id_spec.rb | spec/jwt/claims/jwt_id_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::JwtId do
let(:jti) { 'some-random-uuid-or-whatever' }
let(:payload) { { 'jti' => jti } }
let(:validator) { nil }
subject(:verify!) { described_class.new(validator: validator).verify!(context: SpecSupport::Token.new(payload: payload)) }
context 'when ... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/issuer_spec.rb | spec/jwt/claims/issuer_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::Issuer do
let(:issuer) { 'ruby-jwt-gem' }
let(:payload) { { 'iss' => issuer } }
let(:expected_issuers) { 'ruby-jwt-gem' }
subject(:verify!) { described_class.new(issuers: expected_issuers).verify!(context: SpecSupport::Token.new(payload: payload)) }
... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/spec/jwt/claims/verifier_spec.rb | spec/jwt/claims/verifier_spec.rb | # frozen_string_literal: true
RSpec.describe JWT::Claims::Verifier do
describe '.verify!' do
context 'when all claims are given' do
let(:options) do
[
:exp,
:nbf,
{ iss: 'issuer' },
:iat,
:jti,
{ aud: 'aud' },
:sub,
:cr... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt.rb | lib/jwt.rb | # frozen_string_literal: true
require 'jwt/version'
require 'jwt/base64'
require 'jwt/json'
require 'jwt/decode'
require 'jwt/configuration'
require 'jwt/encode'
require 'jwt/error'
require 'jwt/jwk'
require 'jwt/claims'
require 'jwt/encoded_token'
require 'jwt/token'
# JSON Web Token implementation
#
# Should be up ... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/version.rb | lib/jwt/version.rb | # frozen_string_literal: true
# JSON Web Token implementation
#
# Should be up to date with the latest spec:
# https://tools.ietf.org/html/rfc7519
module JWT
# Returns the gem version of the JWT library.
#
# @return [Gem::Version] the gem version.
def self.gem_version
Gem::Version.new(VERSION::STRING)
en... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/encoded_token.rb | lib/jwt/encoded_token.rb | # frozen_string_literal: true
module JWT
# Represents an encoded JWT token
#
# Processing an encoded and signed token:
#
# token = JWT::Token.new(payload: {pay: 'load'})
# token.sign!(algorithm: 'HS256', key: 'secret')
#
# encoded_token = JWT::EncodedToken.new(token.jwt)
# encoded_token.verif... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/json.rb | lib/jwt/json.rb | # frozen_string_literal: true
require 'json'
module JWT
# @api private
class JSON
class << self
def generate(data)
::JSON.generate(data)
end
def parse(data)
::JSON.parse(data)
end
end
end
end
| ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/x5c_key_finder.rb | lib/jwt/x5c_key_finder.rb | # frozen_string_literal: true
module JWT
# If the x5c header certificate chain can be validated by trusted root
# certificates, and none of the certificates are revoked, returns the public
# key from the first certificate.
# See https://tools.ietf.org/html/rfc7515#section-4.1.6
class X5cKeyFinder
def ini... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/claims.rb | lib/jwt/claims.rb | # frozen_string_literal: true
require_relative 'claims/audience'
require_relative 'claims/crit'
require_relative 'claims/decode_verifier'
require_relative 'claims/expiration'
require_relative 'claims/issued_at'
require_relative 'claims/issuer'
require_relative 'claims/jwt_id'
require_relative 'claims/not_before'
requi... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/base64.rb | lib/jwt/base64.rb | # frozen_string_literal: true
require 'base64'
module JWT
# Base64 encoding and decoding
# @api private
class Base64
class << self
# Encode a string with URL-safe Base64 complying with RFC 4648 (not padded).
# @api private
def url_encode(str)
::Base64.urlsafe_encode64(str, padding:... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwa.rb | lib/jwt/jwa.rb | # frozen_string_literal: true
require 'openssl'
require_relative 'jwa/signing_algorithm'
require_relative 'jwa/ecdsa'
require_relative 'jwa/hmac'
require_relative 'jwa/none'
require_relative 'jwa/ps'
require_relative 'jwa/rsa'
require_relative 'jwa/unsupported'
module JWT
# The JWA module contains all supported al... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwk.rb | lib/jwt/jwk.rb | # frozen_string_literal: true
require_relative 'jwk/key_finder'
require_relative 'jwk/set'
module JWT
# JSON Web Key (JWK)
module JWK
class << self
def create_from(key, params = nil, options = {})
if key.is_a?(Hash)
jwk_kty = key[:kty] || key['kty']
raise JWT::JWKError, 'Key ... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/configuration.rb | lib/jwt/configuration.rb | # frozen_string_literal: true
require_relative 'configuration/container'
module JWT
# The Configuration module provides methods to configure JWT settings.
module Configuration
# Configures the JWT settings.
#
# @yield [config] Gives the current configuration to the block.
# @yieldparam config [JWT... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/token.rb | lib/jwt/token.rb | # frozen_string_literal: true
module JWT
# Represents a JWT token
#
# Basic token signed using the HS256 algorithm:
#
# token = JWT::Token.new(payload: {pay: 'load'})
# token.sign!(algorithm: 'HS256', key: 'secret')
# token.jwt # => eyJhb....
#
# Custom headers will be combined with generated h... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/encode.rb | lib/jwt/encode.rb | # frozen_string_literal: true
require_relative 'jwa'
module JWT
# The Encode class is responsible for encoding JWT tokens.
class Encode
# Initializes a new Encode instance.
#
# @param options [Hash] the options for encoding the JWT token.
# @option options [Hash] :payload the payload of the JWT to... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/error.rb | lib/jwt/error.rb | # frozen_string_literal: true
module JWT
# The EncodeError class is raised when there is an error encoding a JWT.
class EncodeError < StandardError; end
# The DecodeError class is raised when there is an error decoding a JWT.
class DecodeError < StandardError; end
# The VerificationError class is raised wh... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/decode.rb | lib/jwt/decode.rb | # frozen_string_literal: true
require 'json'
require 'jwt/x5c_key_finder'
module JWT
# The Decode class is responsible for decoding and verifying JWT tokens.
class Decode
# Order is very important - first check for string keys, next for symbols
ALGORITHM_KEYS = ['algorithm',
:algorit... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwk/rsa.rb | lib/jwt/jwk/rsa.rb | # frozen_string_literal: true
module JWT
module JWK
# JSON Web Key (JWK) representation of a RSA key
class RSA < KeyBase # rubocop:disable Metrics/ClassLength
BINARY = 2
KTY = 'RSA'
KTYS = [KTY, OpenSSL::PKey::RSA, JWT::JWK::RSA].freeze
RSA_PUBLIC_KEY_ELEMENTS = %i[kty n e].free... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwk/key_finder.rb | lib/jwt/jwk/key_finder.rb | # frozen_string_literal: true
module JWT
module JWK
# JSON Web Key keyfinder
# To find the key for a given kid
class KeyFinder
# Initializes a new KeyFinder instance.
# @param [Hash] options the options to create a KeyFinder with
# @option options [Proc, JWT::JWK::Set] :jwks the jwks or... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwk/set.rb | lib/jwt/jwk/set.rb | # frozen_string_literal: true
require 'forwardable'
module JWT
module JWK
# JSON Web Key Set (JWKS) representation
# https://tools.ietf.org/html/rfc7517
class Set
include Enumerable
extend Forwardable
attr_reader :keys
def initialize(jwks = nil, options = {}) # rubocop:disable ... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwk/key_base.rb | lib/jwt/jwk/key_base.rb | # frozen_string_literal: true
module JWT
module JWK
# Base for JWK implementations
class KeyBase
def self.inherited(klass)
super
::JWT::JWK.classes << klass
end
def initialize(options, params = {})
options ||= {}
@parameters = params.transform_keys(&:to_sym... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwk/ec.rb | lib/jwt/jwk/ec.rb | # frozen_string_literal: true
require 'forwardable'
module JWT
module JWK
# JWK representation for Elliptic Curve (EC) keys
class EC < KeyBase # rubocop:disable Metrics/ClassLength
KTY = 'EC'
KTYS = [KTY, OpenSSL::PKey::EC, JWT::JWK::EC].freeze
BINARY = 2
EC_PUBLIC_KEY_ELEMENTS ... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwk/hmac.rb | lib/jwt/jwk/hmac.rb | # frozen_string_literal: true
module JWT
module JWK
# JWK for HMAC keys
class HMAC < KeyBase
KTY = 'oct'
KTYS = [KTY, String, JWT::JWK::HMAC].freeze
HMAC_PUBLIC_KEY_ELEMENTS = %i[kty].freeze
HMAC_PRIVATE_KEY_ELEMENTS = %i[k].freeze
HMAC_KEY_ELEMENTS = (HMAC_PRIVATE_KEY_ELEMENTS... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwk/kid_as_key_digest.rb | lib/jwt/jwk/kid_as_key_digest.rb | # frozen_string_literal: true
module JWT
module JWK
# @api private
class KidAsKeyDigest
def initialize(jwk)
@jwk = jwk
end
def generate
@jwk.key_digest
end
end
end
end
| ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/jwk/thumbprint.rb | lib/jwt/jwk/thumbprint.rb | # frozen_string_literal: true
module JWT
module JWK
# https://tools.ietf.org/html/rfc7638
class Thumbprint
attr_reader :jwk
def initialize(jwk)
@jwk = jwk
end
def generate
::Base64.urlsafe_encode64(
Digest::SHA256.digest(
JWT::JSON.generate(
... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/configuration/decode_configuration.rb | lib/jwt/configuration/decode_configuration.rb | # frozen_string_literal: true
module JWT
module Configuration
# The DecodeConfiguration class holds the configuration settings for decoding JWT tokens.
class DecodeConfiguration
# @!attribute [rw] verify_expiration
# @return [Boolean] whether to verify the expiration claim.
# @!attribute ... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/configuration/container.rb | lib/jwt/configuration/container.rb | # frozen_string_literal: true
require_relative 'decode_configuration'
require_relative 'jwk_configuration'
module JWT
module Configuration
# The Container class holds the configuration settings for JWT.
class Container
# @!attribute [rw] decode
# @return [DecodeConfiguration] the decode config... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
jwt/ruby-jwt | https://github.com/jwt/ruby-jwt/blob/7af2ac0e36455b94543e47c3e042e9835b247965/lib/jwt/configuration/jwk_configuration.rb | lib/jwt/configuration/jwk_configuration.rb | # frozen_string_literal: true
require_relative '../jwk/kid_as_key_digest'
require_relative '../jwk/thumbprint'
module JWT
module Configuration
# @api private
class JwkConfiguration
def initialize
self.kid_generator_type = :key_digest
end
def kid_generator_type=(value)
self... | ruby | MIT | 7af2ac0e36455b94543e47c3e042e9835b247965 | 2026-01-04T15:49:29.397481Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.