Skip to content

Commit

Permalink
feat: add omniauth v2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellzc committed Apr 18, 2021
1 parent 3b52d80 commit aa4816b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/sinatra/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem "sinatra", ">= 2.0"
gem "omniauth", ">= 2.0"
gem "omniauth-open-edx", path: "../../"
10 changes: 9 additions & 1 deletion examples/sinatra/app.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
begin
require "sinatra"
require "securerandom"
require "omniauth"
require "omniauth-open-edx"
rescue LoadError
require "rubygems"
require "securerandom"
require "sinatra"
require "omniauth"
require "omniauth-open-edx"
end

set sessions: true
set :session_secret, ENV.fetch("SESSION_SECRET") { SecureRandom.hex(64) }

use Rack::Session::Cookie
use OmniAuth::Builder do
provider :open_edx,
Expand All @@ -24,7 +29,10 @@

get "/" do
<<-HTML
<a href='/auth/open_edx'>Sign in with Open edX</a>
<form method='post' action='/auth/open_edx'>
<input type="hidden" name="authenticity_token" value='#{request.env["rack.session"]["csrf"]}'>
<button type='submit'>Sign in with Open edX</button>
</form>
HTML
end

Expand Down
2 changes: 1 addition & 1 deletion omniauth-open-edx.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_dependency "jwt", ">= 2.0"
spec.add_dependency "omniauth", [">= 1.9", "< 2"]
spec.add_dependency "omniauth", [">= 1.9", "< 3"]
spec.add_dependency "omniauth-oauth2", ">= 1.4"

spec.add_development_dependency "bundler", ">= 2.0"
Expand Down

0 comments on commit aa4816b

Please sign in to comment.