<commit_before>require 'rack/openid'
require 'omniauth/openid/gapps'
require 'omniauth/openid'

module OmniAuth
  module Strategies
    class OpenID
      include OmniAuth::Strategy
      
      attr_accessor :options
      
      IDENTIFIER_URL_PARAMETER = 'openid_url'
      
      AX = {
        :email => 'http://axschema.org/contact/email',
        :name => 'http://axschema.org/namePerson',
        :nickname => 'http://axschema.org/namePerson/friendly',
        :first_name => 'http://axschema.org/namePerson/first',
        :last_name => 'http://axschema.org/namePerson/last',
        :city => 'http://axschema.org/contact/city/home',
        :state => 'http://axschema.org/contact/state/home',
        :website => 'http://axschema.org/contact/web/default',
        :image => 'http://axschema.org/media/image/aspect11'
      }
      
      def initialize(app, store = nil, options = {})
        super(app, options.delete(:name) || :open_id)
        @options = options
        @options[:required] ||= [AX[:email], AX[:first_name], AX[:last_name], 'email', 'fullname']
        @options[:optional] ||= [AX[:nickname], AX[:city], AX[:state], AX[:website], AX[:image], 'postcode', 'nickname']
        @store = store
      end
      
      def dummy_app
        lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header(
          :identifier => identifier,
          :return_to => callback_url,
          :required => @options[:required],
          :optional => @options[:optional]
        )}, []]}
      end
      
      def callback_url
        uri = URI.parse(request.url)
        uri.path += '/callback'
        uri.to_s
      end
      
      def identifier<commit_msg>Don't delete options in OmniAuth strategy. Closes #61.<commit_after>require 'rack/openid'
require 'omniauth/openid/gapps'
require 'omniauth/openid'

module OmniAuth
  module Strategies
    # OmniAuth strategy for connecting via OpenID. This allows for connection
    # to a wide variety of sites, some of which are listed [on the OpenID website](http://openid.net/get-an-openid/).
    class OpenID
      include OmniAuth::Strategy
      
      attr_accessor :options
      
      IDENTIFIER_URL_PARAMETER = 'openid_url'
      
      AX = {
        :email => 'http://axschema.org/contact/email',
        :name => 'http://axschema.org/namePerson',
        :nickname => 'http://axschema.org/namePerson/friendly',
        :first_name => 'http://axschema.org/namePerson/first',
        :last_name => 'http://axschema.org/namePerson/last',
        :city => 'http://axschema.org/contact/city/home',
        :state => 'http://axschema.org/contact/state/home',
        :website => 'http://axschema.org/contact/web/default',
        :image => 'http://axschema.org/media/image/aspect11'
      }
      
      # @param app [Rack Application] Standard Rack middleware application argument.
      # @param store [OpenID Store] The [OpenID Store](http://github.com/openid/ruby-openid/tree/master/lib/openid/store/)
      #   you wish to use. Defaults to OpenID::MemoryStore.
      # @option options [Array] :required The identity fields that are required for the OpenID 
      #   request. May be an ActiveExchange schema URL or an sreg identifier.
      # @option options [Array] :optional The optional attributes for the OpenID request. May
      #   be ActiveExchange or sreg.
      # @option options [Symbol, :open_id] :name The URL segment name for this provider.
      def initialize(app, store = nil, options = {})
        super(app, options[:name] || :open_id)
        @options = options
        @options[:required] ||= [AX[:email], AX[:first_name], AX[:last_name], 'email', 'fullname']
        @options[:optional] ||= [AX[:nickname], AX[:city], AX[:state], AX[:website], AX[:image], 'postcode', 'nickname']
        @store = store
      end
      
      protected
      
      def dummy_app
        lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header(
          :identifier => identifier,
          :return_to => callback_url,
          :required => @options[:required],
          :optional => @options[:optional]
        )}, []]}
      end
      
      def callback_url
        uri = URI.parse(request.url)
        uri.path += '/callback'
        uri.to_s
      end
      
      def identifier
{'fraction_non_alphanumeric': 0.1438563767778037, 'fraction_numerical': 0.002797854977850315, 'mean_word_length': 2.5135135135135136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5144863', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1283, 'n_words': 285}