Skip to content

Commit aa4816b

Browse files
committed
feat: add omniauth v2 support
1 parent 3b52d80 commit aa4816b

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

examples/sinatra/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ source "https://rubygems.org"
22

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

5+
gem "sinatra", ">= 2.0"
6+
gem "omniauth", ">= 2.0"
57
gem "omniauth-open-edx", path: "../../"

examples/sinatra/app.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
begin
22
require "sinatra"
3+
require "securerandom"
34
require "omniauth"
45
require "omniauth-open-edx"
56
rescue LoadError
67
require "rubygems"
8+
require "securerandom"
79
require "sinatra"
810
require "omniauth"
911
require "omniauth-open-edx"
1012
end
1113

14+
set sessions: true
15+
set :session_secret, ENV.fetch("SESSION_SECRET") { SecureRandom.hex(64) }
16+
1217
use Rack::Session::Cookie
1318
use OmniAuth::Builder do
1419
provider :open_edx,
@@ -24,7 +29,10 @@
2429

2530
get "/" do
2631
<<-HTML
27-
<a href='/auth/open_edx'>Sign in with Open edX</a>
32+
<form method='post' action='/auth/open_edx'>
33+
<input type="hidden" name="authenticity_token" value='#{request.env["rack.session"]["csrf"]}'>
34+
<button type='submit'>Sign in with Open edX</button>
35+
</form>
2836
HTML
2937
end
3038

omniauth-open-edx.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
2929
spec.require_paths = ["lib"]
3030

3131
spec.add_dependency "jwt", ">= 2.0"
32-
spec.add_dependency "omniauth", [">= 1.9", "< 2"]
32+
spec.add_dependency "omniauth", [">= 1.9", "< 3"]
3333
spec.add_dependency "omniauth-oauth2", ">= 1.4"
3434

3535
spec.add_development_dependency "bundler", ">= 2.0"

0 commit comments

Comments
 (0)