class

App::Base

Inherits App::Pagination < ActionController::Base < ActionController::Responders < ActionController::Route::Builder < Reference < Object

Constants

Log = ::App::Log.for("controller")

Configure your log source name NOTE:: this is chaining from Log

PARSER_LIST = ["application/json"]
RESPONDER_LIST = ["application/json", "text/html"]

Instance methods

api_key_auth?

Check if request is authenticated via API key

Source
audit_log(action : String, resource_type : String, resource_id : UUID | Nil = nil, organization : Models::Organization | Nil = nil, details : Hash(String, JSON::Any::Type) | Nil = nil)

Log an audit event

Source
authenticated?

Check if user is authenticated (returns boolean)

Source
bad_media_type(error) : AC::Error::ContentResponse

covers no acceptable response format and not an acceptable post format

Source
bad_request(error) : CommonError

400 if bad request

Source
build_search_params(query : String = "*", limit : UInt32 = DEFAULT_LIMIT, offset : UInt32 = 0_u32, sort : String = "name", order : String = "asc", ref : String | Nil = nil, fields : Array(String) = [] of String)
Source
current_api_key

Get current API key from Authorization header

Source
current_organization

Get current organization from session

Source
current_organization=(org : Models::Organization)

Set current organization in session

Source
current_user

Get current user from session, API key, or JWT token

Source
has_permission?(org : Models::Organization, min_permission : Permissions) : Bool

Check if user has at least the specified permission level

Source
invalid_param(error) : AC::Error::ParameterResponse

handles paramater missing or a bad paramater value / format

Source
jwt_has_scope?(scope : String) : Bool

Check if JWT token has a specific scope

Source
jwt_scopes

Get JWT token scopes (if authenticated via JWT) Returns array of scopes from JWT token, or empty array

Source
model_validation(error) : ValidationError

handles model validation errors

Source
require_api_key_scope!(scope : String)

Require API key with specific scope

Source
require_auth!

Require authentication

Source
require_organization_access!(org : Models::Organization)

Require organization membership

Source
require_permission!(org : Models::Organization, min_permission : Permissions)

Require specific permission level in organization

Source
resource_access_forbidden(error) : Nil

403 if user role invalid for a route

Source
resource_not_found(error) : CommonError

404 if resource not present

Source
resource_requires_authentication(error) : CommonError

401 if no bearer token

Source
search_params
Source
search_params?
Source
set_date_header
Source
set_request_id

This makes it simple to match client requests with server side logs. When building microservices this ID should be propagated to upstream services.

Source
user_organizations

Get user's organizations

Source
user_permission_in_org(org : Models::Organization) : Permissions | Nil

Get user's permission in an organization

Source

Nested types