class

PublicApi

Inherits Shield::PasswordResetPipes < Shield::Api::PasswordResetPipes < Shield::EmailConfirmationPipes < Shield::Api::EmailConfirmationPipes < Shield::LoginPipes < Shield::Api::LoginPipes < Shield::Api::BearerLoginPipes < Shield::PasswordResetHelpers < Shield::Api::PasswordResetHelpers < Shield::EmailConfirmationHelpers < Shield::Api::EmailConfirmationHelpers < Shield::LoginHelpers < Shield::Api::LoginHelpers < Shield::Api::BearerLoginHelpers < Shield::ActionPipes < Shield::ActionHelpers < Lucille::ActionHelpers < Lucky::Paginator::BackendHelpers < Shield::ApiAction < Lucky::Action < Lucky::VerifyAcceptsFormat < Lucky::Redirectable < Habitat::SettingsHelpers < Habitat::TempConfig < Lucky::RequestBodyLimit < Lucky::ActionPipes < Lucky::ParamHelpers < Lucky::Renderable < Lucky::Routable < Lucky::Exposable < Lucky::RequestTypeHelpers < Lucky::ActionDelegates < Reference < Object

This action accepts both Login and BearerLogin tokens for delegated authorization purposes.

Use this to build an API to be consumed by the public, and by third-party applications.

Because any token type is accepted, bearer tokens retrieved from the Authorization header MUST NOT be used as proof of authentication.

Constants

ACCEPTED_FORMAT_SYMBOLS = [:json]
AFTER_PIPES = [set_previous_page_url] of Symbol

This action accepts both Login and BearerLogin tokens for delegated authorization purposes.

Use this to build an API to be consumed by the public, and by third-party applications.

Because any token type is accepted, bearer tokens retrieved from the Authorization header MUST NOT be used as proof of authentication.

BEFORE_PIPES = [verify_accepted_format, disable_caching, require_logged_in, require_logged_out, pin_login_to_ip_address, enforce_login_idle_timeout, check_authorization] of Symbol

This action accepts both Login and BearerLogin tokens for delegated authorization purposes.

Use this to build an API to be consumed by the public, and by third-party applications.

Because any token type is accepted, bearer tokens retrieved from the Authorization header MUST NOT be used as proof of authentication.

EXPOSURES = [] of Symbol

This action accepts both Login and BearerLogin tokens for delegated authorization purposes.

Use this to build an API to be consumed by the public, and by third-party applications.

Because any token type is accepted, bearer tokens retrieved from the Authorization header MUST NOT be used as proof of authentication.

PARAM_DECLARATIONS = [] of Crystal::Macros::TypeDeclaration

This action accepts both Login and BearerLogin tokens for delegated authorization purposes.

Use this to build an API to be consumed by the public, and by third-party applications.

Because any token type is accepted, bearer tokens retrieved from the Authorization header MUST NOT be used as proof of authentication.

ROUTE_SETTINGS = { prefix: "/api/v0"}

This action accepts both Login and BearerLogin tokens for delegated authorization purposes.

Use this to build an API to be consumed by the public, and by third-party applications.

Because any token type is accepted, bearer tokens retrieved from the Authorization header MUST NOT be used as proof of authentication.

SKIPPED_PIPES = [pin_login_to_ip_address] of Symbol

This action accepts both Login and BearerLogin tokens for delegated authorization purposes.

Use this to build an API to be consumed by the public, and by third-party applications.

Because any token type is accepted, bearer tokens retrieved from the Authorization header MUST NOT be used as proof of authentication.

Class methods

_accepted_formats

Instance methods

authorize?(__arg0 : Shield::User) : Bool | Nil
Source
authorize?
bearer_logged_in?
bearer_logged_out?
bearer_scope
Source
check_authorization
current_bearer
current_bearer?
current_bearer_login
current_bearer_login?
current_login
current_login?
current_user
current_user?
current_user_or_bearer

DEPRECATED User #current_user instead

current_user_or_bearer?

DEPRECATED User #current_user? instead

disable_caching
do_check_authorization_failed
do_enforce_login_idle_timeout_failed
do_pin_email_confirmation_to_ip_address_failed
Source
do_pin_login_to_ip_address_failed
do_pin_password_reset_to_ip_address_failed
Source
do_require_logged_in_failed
do_require_logged_out_failed
enforce_login_idle_timeout
logged_in?
logged_out?
paginator_per_page

The number of records to display per page. Defaults to 25

You can override this in your actions

Example

abstract class BrowserAction < Lucky::Action
  include Lucky::Paginator::BackendHelpers

  # Set to a new static value
  def paginator_per_page : Int32
    50 # defaults to 25
  end

  # Or you could allow setting the number from a param
  def paginator_per_page : Int32
    params.get?(:per_page).try(&.to_i) || 25
  end
end
Source
pin_email_confirmation_to_ip_address
Source
pin_login_to_ip_address
pin_password_reset_to_ip_address
Source
previous_page_url
previous_page_url?
redirect_back(*, fallback : Lucky::Action.class, status : HTTP::Status, allow_external = false)
redirect_back(*, fallback : Lucky::RouteHelper, status : HTTP::Status, allow_external = false)
redirect_back(*, fallback : String, status : Int32 = 302, allow_external : Bool = false)

Redirects the browser to the page that issued the request (the referrer) if possible, otherwise redirects to the provided default fallback location.

The referrer information is pulled from the 'Referer' header on the request. This is an optional header, and if the request is missing this header the fallback will be used.

redirect_back fallback: "/users"

A redirect status can be specified

redirect_back fallback: "/home", status: 301

External referrers are ignored by default. It is determined by comparing the referer header to the request host. They can be explicitly allowed if necessary

redirect_back fallback: "/home", allow_external: true

If the referer path matches the current request path, the fallback will be used to avoid redirecting back to the same page.

remote_ip
remote_ip?
require_logged_in
require_logged_out
return_url
return_url?
set_no_referrer_policy
set_previous_page_url

Macros

authorize
authorize_user