pkce
An OAuth Proof Key for Code Exchange (PKCE) challenge and code verifier.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.9%) to scientific vocabulary
Keywords
oauth
oauth2
pkce
pkce-authentication
security
Last synced: 6 months ago
·
JSON representation
·
Repository
An OAuth Proof Key for Code Exchange (PKCE) challenge and code verifier.
Basic Info
- Host: GitHub
- Owner: bkuhlmann
- License: other
- Language: Ruby
- Default Branch: main
- Homepage: https://alchemists.io/projects/pkce
- Size: 189 KB
Statistics
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
oauth
oauth2
pkce
pkce-authentication
security
Created over 3 years ago
· Last pushed 9 months ago
Metadata Files
Readme
Funding
License
Citation
README.adoc
:rfc_link: link:https://datatracker.ietf.org/doc/html/rfc7636[RFC 7636]
:toc: macro
:toclevels: 5
:figure-caption!:
= Proof Key for Code Exchange (PKCE)
‼️ *This gem is deprecated and will be fully destroyed on 2026-01-15. There is no replacement. Please update accordingly.* ‼️
Proof Key for Code Exchange (PKCE) is an authorization code flow extension to link:https://oauth.net[OAuth] which is necessary for mobile authentication but works well for web flows because the added security is transparent to the user. Specifically, PKCE prevents the following types of attacks:
* Authorization code interception
* Authorization code injection
This gem is an implementation of the {rfc_link} specification so you can leverage PKCE in your own code.
toc::[]
== Features
- Implements the {rfc_link} specification.
- Provides a simple object API for obtaining a challenge and verify code.
- Provides max length security by default.
- Answers a monad result.
== Requirements
. link:https://www.ruby-lang.org[Ruby].
. link:https://www.oauth.com[OAuth].
== Setup
To install _with_ security, run:
[source,bash]
----
# 💡 Skip this line if you already have the public certificate installed.
gem cert --add <(curl --compressed --location https://alchemists.io/gems.pem)
gem install pkce --trust-policy HighSecurity
----
To install _without_ security, run:
[source,bash]
----
gem install pkce
----
You can also add the gem directly to your project:
[source,bash]
----
bundle add pkce
----
Once the gem is installed, you only need to require it:
[source,ruby]
----
require "pkce"
----
== Usage
The object API is simple to work with as you only need to interact with the `PKCE` constant. Example:
[source,ruby]
----
code = PKCE.call.success
code.challenge # e2tGChTfGON-C55i0yu13-urIgDFuMCmo73F7TZmoiw
code.verify # hYnx2WTJo7Bgu1-GqPUIYtRkb2W7pRBawkmdDi3omPdramb27Fp4rps_w6ozns-gbVCKFC2-Kno4P_b1H3FuxnlYIOd9Bo5yoTXq_xEHDJaB_fOfn2NaiCtcWQ8Bs91I
----
You can also pass in a custom length (default is maximum):
[source,ruby]
----
code = PKCE.call(length: 35).success
code.challenge # R1b1Ka3jmrLKvQ7xW5QmP5MsCSEWtdoA2lo3r-SZDfg
code.verify # ucKkqwoMzc9cyPcSGMbuVf3ivr4sep2mq15hGN9sVzl4X7g
----
In case of a failure, you'll get a proper error message:
[source,ruby]
----
PKCE.call(length: 100).failure # Invalid PKCE verifier length: 100. Must be between 32..96.
----
Due to the fact that PKCE answers back a link:https://dry-rb.org/gems/dry-monads[monad], you have all of the power of link:https://alchemists.io/talks/ruby_pattern_matching[pattern matching] at your fingertips as well:
[source,ruby]
----
include Dry::Monads[:result]
case PKCE.call
in Success(code) then puts code.inspect
in Failure(message) then puts message
end
----
Finally, since the code answered back is a link:https://alchemists.io/articles/ruby_data[Data] object that you can easily test and interact with:
[source,ruby]
----
PKCE.call.success
#
----
== Development
To contribute, run:
[source,bash]
----
git clone https://github.com/bkuhlmann/pkce
cd pkce
bin/setup
----
You can also use the IRB console for direct access to all objects:
[source,bash]
----
bin/console
----
=== Architecture
The following documents the workflow used to process and build authorization codes.
image::https://alchemists.io/images/projects/pkce/doc/sequence_diagram.svg[Sequence Diagram]
== Tests
To test, run:
[source,bash]
----
bin/rake
----
== link:https://alchemists.io/policies/license[License]
== link:https://alchemists.io/policies/security[Security]
== link:https://alchemists.io/policies/code_of_conduct[Code of Conduct]
== link:https://alchemists.io/policies/contributions[Contributions]
== link:https://alchemists.io/policies/developer_certificate_of_origin[Developer Certificate of Origin]
== link:https://alchemists.io/projects/pkce/versions[Versions]
== link:https://alchemists.io/community[Community]
== Credits
* Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].
* Engineered by link:https://alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
Owner
- Name: Brooke Kuhlmann
- Login: bkuhlmann
- Kind: user
- Location: Boulder, CO USA
- Company: Alchemists
- Website: https://alchemists.io
- Repositories: 56
- Profile: https://github.com/bkuhlmann
Quality over quantity.
Citation (CITATION.cff)
cff-version: 1.2.0
message: Please use the following metadata when citing this project in your work.
title: PKCE
abstract: An OAuth Proof Key for Code Exchange (PKCE) challenge and code verifier.
version: 3.2.1
license: Hippocratic-2.1
date-released: 2025-06-05
authors:
- family-names: Kuhlmann
given-names: Brooke
affiliation: Alchemists
orcid: https://orcid.org/0000-0002-5810-6268
keywords:
- ruby
- pkce
- oauth
repository-code: https://github.com/bkuhlmann/pkce
repository-artifact: https://rubygems.org/gems/pkce
url: https://alchemists.io/projects/pkce
GitHub Events
Total
- Watch event: 1
- Delete event: 41
- Push event: 24
- Create event: 7
Last Year
- Watch event: 1
- Delete event: 41
- Push event: 24
- Create event: 7
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 53
- Total Committers: 1
- Avg Commits per committer: 53.0
- Development Distribution Score (DDS): 0.0
Top Committers
| Name | Commits | |
|---|---|---|
| Brooke Kuhlmann | b****e@a****o | 53 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- rubygems 68,450 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 24
- Total maintainers: 1
rubygems.org: pkce
An OAuth Proof Key for Code Exchange (PKCE) challenge and code verifier.
- Homepage: https://alchemists.io/projects/pkce
- Documentation: http://www.rubydoc.info/gems/pkce/
- License: Hippocratic-2.1
-
Latest release: 3.2.1
published 9 months ago
Rankings
Dependent packages count: 15.7%
Forks count: 31.4%
Stargazers count: 35.1%
Average: 45.0%
Dependent repos count: 46.8%
Downloads: 96.2%
Maintainers (1)
Funding
- https://github.com/sponsors/bkuhlmann
Last synced:
6 months ago
Dependencies
Gemfile
rubygems
- amazing_print ~> 1.4 development
- caliber ~> 0.9 development
- debug ~> 1.5 development
- git-lint ~> 4.0 development
- guard-rspec ~> 4.7 development
- rake ~> 13.0 development
- reek ~> 6.1 development
- refinements ~> 9.4 development
- rspec ~> 3.11 development
- simplecov ~> 0.21 development
pkce.gemspec
rubygems
- dry-monads ~> 1.4