# cbSecurity Model

## Explicit Authorizations

The `cbSecurity` model is a specialized service that will allow you to do explicit authorizations in any layer of your ColdBox application.

Sometimes, you will need authorization checks outside of the incoming request rules or the handler annotations. This can be from within interceptors, models, layouts, or views. For this, we have provided the `cbSecurity` model so you can do explicit authorization checks anywhere you like.

## `cbSecurity` Model Retrieval

You can inject our model, or you can use our handy `cbsecure()` mixin (handlers/layouts/views) and then call the appropriate security functions:

```javascript
// Mixin: Handlers/Layouts/Views
cbsecure()

// Injection
property name="cbSecurity" inject="@cbSecurity"
```

{% hint style="danger" %}
All security methods will call the application's configured Authentication Service to retrieve the currently logged-in user. If the user is not logged in, an immediate `NoUserLoggedIn` exception will be thrown by all methods.
{% endhint %}

You can now discover our sections for securing using `cbSecurity`

{% content-ref url="/pages/EkvW0uZCt94XDj2r6EbH" %}
[Authentication Methods](/usage/cbsecurity-model/authentication-methods.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M3gu0RwxlpLSkOo-idX" %}
[Authorization Contexts](/usage/cbsecurity-model/authorization-contexts.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M3gtW4YzTEAf6ylUmoc" %}
[Blocking Methods](/usage/cbsecurity-model/secure-blocking-methods.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M3gu8DR7rp1\_Q9WfJJo" %}
[Securing Views](/usage/cbsecurity-model/securing-views.md)
{% endcontent-ref %}

{% content-ref url="/pages/eA8bHiGeEkS9nCF1E2sT" %}
[Utility Methods](/usage/cbsecurity-model/utility-methods.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M3gtoOkN9PPbFvyKLXp" %}
[Verification Methods](/usage/cbsecurity-model/verification-methods.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://coldbox-security.ortusbooks.com/usage/cbsecurity-model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
