abstract class PublicApi

Overview

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.

Included Modules

Direct Known Subclasses

Defined in:

actions/public_api.cr

Constant Summary

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 Method Summary

Macro Summary

Instance Method Summary

Class Method Detail

def self._accepted_formats : Array(Symbol) #

Macro Detail

macro authorize(&block) #

macro authorize_user(&block) #

Instance Method Detail

def authorize?(__arg0 : Shield::User) : Bool | Nil #

[View source]
def authorize? : Bool | Nil #

def bearer_logged_in? : Bool #

def bearer_logged_out? : Bool #

def bearer_scope : String #

[View source]
def check_authorization #

def current_bearer : User #

def current_bearer? : User | Nil #

def current_bearer_login #

def current_bearer_login? : BearerLogin | Nil #

def current_login #

def current_login? : Login | Nil #

def current_user #

def current_user? : User | Nil #

def current_user_or_bearer : User #

DEPRECATED User #current_user instead


def current_user_or_bearer? : User | Nil #

DEPRECATED User #current_user? instead


def disable_caching #

def do_check_authorization_failed #

def do_enforce_login_idle_timeout_failed #

def do_pin_email_confirmation_to_ip_address_failed #

[View source]
def do_pin_login_to_ip_address_failed #

def do_pin_password_reset_to_ip_address_failed #

[View source]
def do_require_logged_in_failed #

def do_require_logged_out_failed #

def enforce_login_idle_timeout #

def logged_in? : Bool #

def logged_out? : Bool #

def paginator_per_page : Int32 #
Description copied from module Lucky::Paginator::BackendHelpers

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

[View source]
def pin_email_confirmation_to_ip_address #

[View source]
def pin_login_to_ip_address #

def pin_password_reset_to_ip_address #

[View source]
def previous_page_url #

def previous_page_url? : String | Nil #

def redirect_back(*, fallback : Lucky::Action.class, status : HTTP::Status, allow_external = false) #

def redirect_back(*, fallback : Lucky::RouteHelper, status : HTTP::Status, allow_external = false) #

def redirect_back(*, fallback : String, status : Int32 = 302, allow_external : Bool = false) #
Description copied from module Lucky::Redirectable

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.


def remote_ip : Socket::IPAddress #

def remote_ip? : Socket::IPAddress | Nil #

def require_logged_in #

def require_logged_out #

def return_url #

def return_url? : String | Nil #

def set_no_referrer_policy #

def set_previous_page_url #