---
title: "nuxt-backend/authorization"
description: "Every export of nuxt-backend/authorization, with its signature and where it is defined."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/authorization"
---
# nuxt-backend/authorization

## Interfaces

### AuthorizationUser

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

The signed-in user, as read from identity claims.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Better Auth user id (the component's <code>
        user
      </code>
      
       document id).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="email">
        
      </a>
      
       <code>
        email
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="name">
        
      </a>
      
       <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="role">
        
      </a>
      
       <code>
        role
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      App-wide role from the admin plugin; <code>
        'user'
      </code>
      
       when unset.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="banned">
        
      </a>
      
       <code>
        banned
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="activeorganizationid">
        
      </a>
      
       <code>
        activeOrganizationId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      The session's active workspace, or <code>
        null
      </code>
      
       when none.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="impersonatedby">
        
      </a>
      
       <code>
        impersonatedBy
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      The admin impersonating this user, or <code>
        null
      </code>
      
       for the user's own session. Refuse what an impersonating admin must not do: <code>
        if (user.impersonatedBy) throw …
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claims">
        
      </a>
      
       <code>
        claims
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >
    </td>
    
    <td>
      All identity claims, for anything not surfaced above.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AuthorizationMember

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

A workspace membership, as returned by [Authorization.requireMember](#requiremember).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="user">
        
      </a>
      
       <code>
        user
      </code>
    </td>
    
    <td>
      <a href="#authorizationuser">
        <code>
          AuthorizationUser
        </code>
      </a>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="organizationid">
        
      </a>
      
       <code>
        organizationId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="role-1">
        
      </a>
      
       <code>
        role
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The member's role <em>
        within the workspace
      </em>
      
       (owner/admin/member or custom).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AuthorizationCtx

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

Any Convex ctx that can read identity and run component queries.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="auth">
        
      </a>
      
       <code>
        auth
      </code>
    </td>
    
    <td>
      <code>
        Auth
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="runquery">
        
      </a>
      
       <code>
        runQuery
      </code>
    </td>
    
    <td>
      <<code>
        Query
      </code>
      
      >(<code>
        query
      </code>
      
      , ...<code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        FunctionReturnType
      </code>
      
      <<code>
        Query
      </code>
      
      >>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### StatementRole

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

A role with a Better Auth access-control statement check.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="authorize">
        
      </a>
      
       <code>
        authorize
      </code>
    </td>
    
    <td>
      (<code>
        permissions
      </code>
      
      ) => { <code>
        success
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        error?
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### AuthorizationComponents

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

The component handle [setupAuthorization](#setupauthorization) reads from your generated
`components` object: the package's all-in-one `backend` component, whose
auth adapter functions it queries through. Pass the whole `components`
object — the key is picked structurally.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="backend">
        
      </a>
      
       <code>
        backend
      </code>
    </td>
    
    <td>
      { <code>
        adapter
      </code>
      
      : { <code>
        findOne
      </code>
      
      : <code>
        unknown
      </code>
      
      ; <code>
        updateOne
      </code>
      
      : <code>
        unknown
      </code>
      
      ; }; }
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter
      </code>
    </td>
    
    <td>
      { <code>
        findOne
      </code>
      
      : <code>
        unknown
      </code>
      
      ; <code>
        updateOne
      </code>
      
      : <code>
        unknown
      </code>
      
      ; }
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter.findOne
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter.updateOne
      </code>
    </td>
    
    <td>
      <code>
        unknown
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SetupAuthorizationOptions

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
    
    <th>
      Default type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
    
    <td>
      <code>
        GenericDataModel
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="roles">
        
      </a>
      
       <code>
        roles?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#statementrole">
        <code>
          StatementRole
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Statement roles for <a href="#requirepermission">
        Authorization.requirePermission
      </a>
      
       — pass the same <code>
        roles
      </code>
      
       map you gave the admin plugin (<code>
        createAccessControl
      </code>
      
       roles). Defaults to the admin plugin's built-in <code>
        admin
      </code>
      
      /<code>
        user
      </code>
      
       roles.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="internalmutation">
        
      </a>
      
       <code>
        internalMutation?
      </code>
    </td>
    
    <td>
      <code>
        MutationBuilder
      </code>
      
      <<code>
        DM
      </code>
      
      , <code>
        "internal"
      </code>
      
      >
    </td>
    
    <td>
      Your <code>
        internalMutation
      </code>
      
       builder — supplying it adds the <code>
        setUserRole
      </code>
      
       bootstrap mutation (run <code>
        npx convex run functions:setUserRole '{"email":"you@example.com","role":"admin"}'
      </code>
      
       to mint the first admin).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### Authorization

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="getuser">
        
      </a>
      
       <code>
        getUser
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#authorizationuser">
        <code>
          AuthorizationUser
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      The signed-in user from identity claims, or <code>
        null
      </code>
      
       when signed out.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="requireuser">
        
      </a>
      
       <code>
        requireUser
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#authorizationuser">
        <code>
          AuthorizationUser
        </code>
      </a>
      
      >
    </td>
    
    <td>
      The signed-in user; throws <code>
        unauthenticated
      </code>
      
       when signed out, <code>
        forbidden
      </code>
      
       (reason <code>
        banned
      </code>
      
      ) when banned — catalog codes (see <code>
        backendError
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="requirerole">
        
      </a>
      
       <code>
        requireRole
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        role
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#authorizationuser">
        <code>
          AuthorizationUser
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Require an app-wide role. <code>
        fresh: true
      </code>
      
       re-reads the user document past JWT staleness — use it for sensitive checks right after role changes.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="requirepermission">
        
      </a>
      
       <code>
        requirePermission
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        permissions
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#authorizationuser">
        <code>
          AuthorizationUser
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Require permission statements (e.g. <code>
        { user: ['ban'] }
      </code>
      
      ) against the user's role. <code>
        fresh: true
      </code>
      
       re-reads the user document past JWT staleness — use it for permission-gated destructive operations right after role changes.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="requireorganization">
        
      </a>
      
       <code>
        requireOrganization
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        user
      </code>
      
      : <a href="#authorizationuser">
        <code>
          AuthorizationUser
        </code>
      </a>
      
      ; <code>
        organizationId
      </code>
      
      : <code>
        string
      </code>
      
      ; }>
    </td>
    
    <td>
      Require an active workspace on the session; returns its id.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="requiremember">
        
      </a>
      
       <code>
        requireMember
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#authorizationmember">
        <code>
          AuthorizationMember
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Require workspace membership (always a fresh member-table read). Defaults to the active workspace; pass <code>
        role
      </code>
      
       to also require a workspace role.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="setuserrole">
        
      </a>
      
       <code>
        setUserRole?
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "internal"
      </code>
      
      , { <code>
        email
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        role
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      Bootstrap role assignment — present when <code>
        internalMutation
      </code>
      
       was supplied.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts" rel="nofollow">
        src/convex/integrations/authorization.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Variables

### defaultStatements

```ts
const defaultStatements: {
  user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "get", "update"];
  session: readonly ["list", "revoke", "delete"];
};
```

Defined in: node_modules/better-auth/dist/plugins/admin/access/statement.d.mts:3

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="property-user">
        
      </a>
      
       <code>
        user
      </code>
    </td>
    
    <td>
      readonly [<code>
        "create"
      </code>
      
      , <code>
        "list"
      </code>
      
      , <code>
        "set-role"
      </code>
      
      , <code>
        "ban"
      </code>
      
      , <code>
        "impersonate"
      </code>
      
      , <code>
        "impersonate-admins"
      </code>
      
      , <code>
        "delete"
      </code>
      
      , <code>
        "set-password"
      </code>
      
      , <code>
        "set-email"
      </code>
      
      , <code>
        "get"
      </code>
      
      , <code>
        "update"
      </code>
      
      ]
    </td>
    
    <td>
      node_modules/better-auth/dist/plugins/admin/access/statement.d.mts:4
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-session">
        
      </a>
      
       <code>
        session
      </code>
    </td>
    
    <td>
      readonly [<code>
        "list"
      </code>
      
      , <code>
        "revoke"
      </code>
      
      , <code>
        "delete"
      </code>
      
      ]
    </td>
    
    <td>
      node_modules/better-auth/dist/plugins/admin/access/statement.d.mts:5
    </td>
  </tr>
</tbody>
</table>

---

### adminAc

```ts
const adminAc: Role<ExactRoleStatements<{
  user: ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "set-email", "get", "update"];
  session: ["list", "revoke", "delete"];
}>, {
  user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "get", "update"];
  session: readonly ["list", "revoke", "delete"];
}>;
```

Defined in: node_modules/better-auth/dist/plugins/admin/access/statement.d.mts:20

---

### userAc

```ts
const userAc: Role<ExactRoleStatements<{
  user: [];
  session: [];
}>, {
  user: readonly ["create", "list", "set-role", "ban", "impersonate", "impersonate-admins", "delete", "set-password", "set-email", "get", "update"];
  session: readonly ["list", "revoke", "delete"];
}>;
```

Defined in: node_modules/better-auth/dist/plugins/admin/access/statement.d.mts:27

## Functions

### createAccessControl()

```ts
function createAccessControl<TStatements>(s): {
  newRole<TRoleStatements>(statements): Role<ExactRoleStatements<TRoleStatements>, TStatements>;
  statements: TStatements;
};
```

Defined in: node_modules/better-auth/dist/plugins/access/access.d.mts:12

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-tstatements">
        
      </a>
      
       <code>
        TStatements
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        Statements
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        s
      </code>
    </td>
    
    <td>
      <code>
        TStatements
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Returns

```ts
{
  newRole<TRoleStatements>(statements): Role<ExactRoleStatements<TRoleStatements>, TStatements>;
  statements: TStatements;
}
```

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        newRole()
      </code>
    </td>
    
    <td>
      (<code>
        statements
      </code>
      
      ) => <code>
        Role
      </code>
      
      <<code>
        ExactRoleStatements
      </code>
      
      <<code>
        TRoleStatements
      </code>
      
      >, <code>
        TStatements
      </code>
      
      >
    </td>
    
    <td>
      node_modules/better-auth/dist/plugins/access/access.d.mts:13
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        statements
      </code>
    </td>
    
    <td>
      <code>
        TStatements
      </code>
    </td>
    
    <td>
      node_modules/better-auth/dist/plugins/access/access.d.mts:14
    </td>
  </tr>
</tbody>
</table>

---

### setupAuthorization()

```ts
function setupAuthorization<DM>(components, options?): Authorization;
```

Defined in: [src/convex/integrations/authorization.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/authorization.ts)

Build the authorization helpers over the `backend` component's auth adapter.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
    
    <th>
      Default type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-dm-1">
        
      </a>
      
       <code>
        DM
      </code>
      
       <em>
        extends
      </em>
      
       <code>
        GenericDataModel
      </code>
    </td>
    
    <td>
      <code>
        GenericDataModel
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        components
      </code>
    </td>
    
    <td>
      <a href="#authorizationcomponents">
        <code>
          AuthorizationComponents
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#setupauthorizationoptions">
        <code>
          SetupAuthorizationOptions
        </code>
      </a>
      
      <<code>
        DM
      </code>
      
      >
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`Authorization`](#authorization)

#### Example

```ts
// convex/functions.ts
import { setupAuthorization } from 'nuxt-backend/authorization'
import { components } from './_generated/api'
import { internalMutation } from './_generated/server'

export const authorization = setupAuthorization(components, { internalMutation })
export const { requireUser, requireRole, requireOrganization, setUserRole } = authorization
```


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
