Module: GrapeTokenAuth

Extended by:
Forwardable
Defined in:
lib/grape_token_auth/key_generator.rb,
lib/grape_token_auth.rb,
lib/grape_token_auth/token.rb,
lib/grape_token_auth/utility.rb,
lib/grape_token_auth/version.rb,
lib/grape_token_auth/mail/mail.rb,
lib/grape_token_auth/exceptions.rb,
lib/grape_token_auth/middleware.rb,
lib/grape_token_auth/api_helpers.rb,
lib/grape_token_auth/lookup_token.rb,
lib/grape_token_auth/configuration.rb,
lib/grape_token_auth/mount_helpers.rb,
lib/grape_token_auth/authorizer_data.rb,
lib/grape_token_auth/apis/session_api.rb,
lib/grape_token_auth/mail/smtp_mailer.rb,
lib/grape_token_auth/token_authorizer.rb,
lib/grape_token_auth/apis/omniauth_api.rb,
lib/grape_token_auth/apis/password_api.rb,
lib/grape_token_auth/mail/message_base.rb,
lib/grape_token_auth/token_authentication.rb,
lib/grape_token_auth/apis/confirmation_api.rb,
lib/grape_token_auth/apis/registration_api.rb,
lib/grape_token_auth/authentication_header.rb,
lib/grape_token_auth/unauthorized_middleware.rb,
lib/grape_token_auth/resource/resource_finder.rb,
lib/grape_token_auth/apis/registration/helpers.rb,
lib/grape_token_auth/apis/token_validation_api.rb,
lib/grape_token_auth/resource/resource_creator.rb,
lib/grape_token_auth/resource/resource_updater.rb,
lib/grape_token_auth/omniauth/omniauth_resource.rb,
lib/grape_token_auth/omniauth/omniauth_html_base.rb,
lib/grape_token_auth/resource/resource_crud_base.rb,
lib/grape_token_auth/omniauth/omniauth_failure_html.rb,
lib/grape_token_auth/omniauth/omniauth_success_html.rb,
lib/grape_token_auth/apis/registration/endpoint_definer.rb,
lib/grape_token_auth/orm_integrations/active_record_token_auth.rb,
lib/grape_token_auth/mail/messages/confirmation/confirmation_email.rb,
lib/grape_token_auth/mail/messages/password_reset/password_reset_email.rb

Overview

Copied from devise

Defined Under Namespace

Modules: ActiveRecord, ApiHelpers, ConfirmationAPICore, Mail, MountHelpers, OmniAuthAPICore, PasswordAPICore, Registration, RegistrationAPICore, SessionsAPICore, TokenAuthentication, TokenValidationAPICore Classes: AuthenticationHeader, AuthorizerData, CachingKeyGenerator, Configuration, ConfirmationAPI, KeyGenerator, LookupToken, MappingsUndefinedError, Middleware, OmniAuthAPI, OmniAuthCallBackRouterAPI, OmniAuthFailureHTML, OmniAuthHTMLBase, OmniAuthResource, OmniAuthSuccessHTML, PasswordAPI, RegistrationAPI, ResourceCreator, ResourceCrudBase, ResourceFinder, ResourceUpdater, ScopeUndefinedError, SecretNotSet, SessionsAPI, Token, TokenAuthorizer, TokenValidationAPI, Unauthorized, UnauthorizedMiddleware, Utility

Constant Summary collapse

VERSION =
'0.1.1'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



57
58
59
# File 'lib/grape_token_auth.rb', line 57

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



53
54
55
# File 'lib/grape_token_auth.rb', line 53

def configure
  yield configuration if block_given?
end

.send_notification(notification_type, opts) ⇒ Object



81
82
83
84
# File 'lib/grape_token_auth.rb', line 81

def send_notification(notification_type, opts)
  message = GrapeTokenAuth::Mail.initialize_message(notification_type, opts)
  configuration.mailer.send!(message, opts)
end

.set_omniauth_path_prefix!Object



77
78
79
# File 'lib/grape_token_auth.rb', line 77

def set_omniauth_path_prefix!
  ::OmniAuth.config.path_prefix = configuration.omniauth_prefix
end

.setup!(&block) ⇒ Object



65
66
67
68
# File 'lib/grape_token_auth.rb', line 65

def setup!(&block)
  add_auth_strategy
  configure(&block) if block_given?
end

.setup_warden!(builder) ⇒ Object



70
71
72
73
74
75
# File 'lib/grape_token_auth.rb', line 70

def setup_warden!(builder)
  builder.use Warden::Manager do |manager|
    manager.failure_app = GrapeTokenAuth::UnauthorizedMiddleware
    manager.default_scope = :user
  end
end