File: sinatra.rb

package info (click to toggle)
ruby-omniauth-openid 2.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 140 kB
  • sloc: ruby: 196; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 566 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'rubygems'
require 'bundler'

Bundler.setup :default, :development, :example
require 'sinatra'
require 'omniauth-openid'
require 'openid/store/filesystem'

use Rack::Session::Cookie

use OmniAuth::Builder do
  provider :open_id, store: OpenID::Store::Filesystem.new('/tmp')
end

get '/' do
  <<-HTML
  <ul>
    <li><a href='/auth/open_id'>Sign in with OpenID</a></li>
  </ul>
  HTML
end

[:get, :post].each do |method|
  send method, '/auth/:provider/callback' do
    content_type 'text/plain'
    request.env['omniauth.auth'].info.to_hash.inspect
  end
end