Sha256: f44b45196273a15d6dcaf51c36e852c5311eb185996702c3b6ba9ca8da2ffef3
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require "omniauth" require "omniauth/strategies/discourse/sso" module OmniAuth module Strategies class Discourse include OmniAuth::Strategy args [:sso_secret, :sso_url] option :sso_secret, nil option :sso_url, nil attr_reader :user_info def request_phase sso = SSO.new(options.sso_secret, options.sso_url, callback_url) session[:sso_nonce] = sso.nonce redirect sso.request_url end def callback_phase sso = SSO.new(options.sso_secret, options.sso_url, callback_url, session[:sso_nonce]) sso.parse(request.params) raise OmniAuth::NoSessionError, "Username or password are not valid" if sso.status == "error" @user_info = sso.user_info super rescue OmniAuth::NoSessionError => e fail!(:invalid_credentials, e) end uid do user_info[:external_id] end info do { "name" => user_info[:name], "email" => user_info[:email], "nickname" => user_info[:username] } end extra do { "admin" => user_info[:admin] == "true", "moderator" => user_info[:moderator] == "true" } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omniauth-discourse-1.0.0 | lib/omniauth/strategies/discourse.rb |