moduleDoorkeeperclassMissingConfiguration<StandardErrordefinitializesuper('Configuration for doorkeeper missing. Do you have doorkeeper initializer?')endenddefself.configure(&block)@config=Config::Builder.new(&block).buildenable_ormsetup_application_ownerif@config.enable_application_owner?enddefself.configuration@config||(failMissingConfiguration.new)enddefself.orm_model_dircaseconfiguration.ormwhen:mongoid3,:mongoid4'mongoid3_4'elseconfiguration.ormendenddefself.enable_ormrequire"doorkeeper/models/#{orm_model_dir}/access_grant"require"doorkeeper/models/#{orm_model_dir}/access_token"require"doorkeeper/models/#{orm_model_dir}/application"require'doorkeeper/models/access_grant'require'doorkeeper/models/access_token'require'doorkeeper/models/application'enddefself.setup_application_ownerrequireFile.join(File.dirname(__FILE__),'models','ownership')Doorkeeper::Application.send:include,Doorkeeper::Models::OwnershipendclassConfigclassBuilderdefinitialize(&block)@config=Config.newinstance_eval(&block)enddefbuild@configenddefenable_application_owner(opts={})@config.instance_variable_set('@enable_application_owner',true)confirm_application_ownerifopts[:confirmation].present?&&opts[:confirmation]enddefconfirm_application_owner@config.instance_variable_set('@confirm_application_owner',true)enddefdefault_scopes(*scopes)@config.instance_variable_set('@default_scopes',Doorkeeper::OAuth::Scopes.from_array(scopes))enddefoptional_scopes(*scopes)@config.instance_variable_set('@optional_scopes',Doorkeeper::OAuth::Scopes.from_array(scopes))enddefclient_credentials(*methods)@config.instance_variable_set('@client_credentials',methods)enddefaccess_token_methods(*methods)@config.instance_variable_set('@access_token_methods',methods)enddefuse_refresh_token@config.instance_variable_set('@refresh_token_enabled',true)enddefrealm(realm)@config.instance_variable_set('@realm',realm)enddefreuse_access_token@config.instance_variable_set("@reuse_access_token",true)enddeftest_redirect_uri(uri)warn<<-TEXT
DEPRECATION: test_redirect_uri has renamed to native_redirect_uri. use "native_redirect_uri '#{uri}'".
TEXT@config.instance_variable_set('@native_redirect_uri',uri)endendmoduleOption# Defines configuration option## When you call option, it defines two methods. One method will take place# in the +Config+ class and the other method will take place in the# +Builder+ class.## The +name+ parameter will set both builder method and config attribute.# If the +:as+ option is defined, the builder method will be the specified# option while the config attribute will be the +name+ parameter.## If you want to introduce another level of config DSL you can# define +builder_class+ parameter.# Builder should take a block as the initializer parameter and respond to function +build+# that returns the value of the config attribute.## ==== Options## * [:+as+] Set the builder method that goes inside +configure+ block# * [+:default+] The default value in case no option was set## ==== Examples## option :name# option :name, as: :set_name# option :name, default: 'My Name'# option :scopes builder_class: ScopesBuilder#defoption(name,options={})attribute=options[:as]||nameattribute_builder=options[:builder_class]Builder.instance_evaldodefine_methodnamedo|*args,&block|# TODO: is builder_class option being used?value=unlessattribute_builderblock?block:args.firstelseattribute_builder.new(&block).buildend@config.instance_variable_set(:"@#{attribute}",value)endenddefine_methodattributedo|*args|ifinstance_variable_defined?(:"@#{attribute}")instance_variable_get(:"@#{attribute}")elseoptions[:default]endendpublicattributeenddefextended(base)base.send(:private,:option)endendextendOptionoption:resource_owner_authenticator,as: :authenticate_resource_owner,default: (lambdado|routes|logger.warn(I18n.translate('doorkeeper.errors.messages.resource_owner_authenticator_not_configured'))nilend)option:admin_authenticator,as: :authenticate_admin,default: ->(routes){}option:resource_owner_from_credentials,default: (lambdado|routes|warn(I18n.translate('doorkeeper.errors.messages.credential_flow_not_configured'))nilend)option:skip_authorization,default: ->(routes){}option:access_token_expires_in,default: 7200option:authorization_code_expires_in,default: 600option:orm,default: :active_recordoption:native_redirect_uri,default: 'urn:ietf:wg:oauth:2.0:oob'option:active_record_options,default: {}option:realm,default: 'Doorkeeper'option:wildcard_redirect_uri,default: falseoption:grant_flows,default: %w(authorization_code implicit password client_credentials)attr_reader:reuse_access_tokendefrefresh_token_enabled?!!@refresh_token_enabledenddefenable_application_owner?!!@enable_application_ownerenddefconfirm_application_owner?!!@confirm_application_ownerenddefdefault_scopes@default_scopes||=Doorkeeper::OAuth::Scopes.newenddefoptional_scopes@optional_scopes||=Doorkeeper::OAuth::Scopes.newenddefscopes@scopes||=default_scopes+optional_scopesenddeform_name[:mongoid2,:mongoid3,:mongoid4].include?(orm)?:mongoid:ormenddefclient_credentials_methods@client_credentials||=[:from_basic,:from_params]enddefaccess_token_methods@access_token_methods||=[:from_bearer_authorization,:from_access_token_param,:from_bearer_param]enddefrealm@realm||='Doorkeeper'enddefauthorization_response_types@authorization_response_types||=calculate_authorization_response_typesenddeftoken_grant_types@token_grant_types||=calculate_token_grant_typesendprivate# Determines what values are acceptable for 'response_type' param in# authorization request endpoint, and return them as an array of strings.#defcalculate_authorization_response_typestypes=[]types<<'code'ifgrant_flows.include?'authorization_code'types<<'token'ifgrant_flows.include?'implicit'typesend# Determines what values are acceptable for 'grant_type' param token# request endpoint, and return them in array.#defcalculate_token_grant_typestypes=grant_flows-['implicit']types<<'refresh_token'ifrefresh_token_enabled?typesendendend