# Modules

Here you find information about modules

# Auth

Auth class ZXC\Modules\Auth\Auth allow you to authenticate users in your application. Behaviour of this module depends on given options.
Options example

{
    "class": "ZXC\\Modules\\Auth\\Auth",
    "defer": false,
    "options": {
        "storageProvider": "ZXC\\Modules\\Auth\\Storages\\AuthPgSqlStorage",
        "authTypeProvider": "ZXC\\Modules\\Auth\\Providers\\AuthJwtTokenProvider",
        "remindPasswordInterval": 1,
        "remindPasswordLinkTemplate": "http://localhost:3000/#/?resetCode={code}&login={login}",
        "remindPasswordEmailBody": "<p> Reset password! {link} </p>",
        "remindPasswordLinkProvider": "ZXC\\Modules\\Auth\\Providers\\AuthSendReminderLink",
        "authTypeProviderOptions": {
            "secret": "[)1231&^^*&^%00()(]",
            "alg": "HS256",
            "accessLifeTime": 200,
            "refreshLifetime": 400,
            "tokenStorage": "ZXC\\Modules\\Auth\\Storages\\AuthTokenStoragePgSql"
        },
        "email": {
            "confirm": true,
            "codeProvider": "ZXC\\Modules\\Auth\\Providers\\AuthConfirmCodeProvider",
            "confirmUrlTemplate": "http://tvapi.localhost/confirm/email/{code}/login/{login}",
            "body": "<p> Welcome to the TaskView app! {link} </p>",
            "redirectAfterConfirm": "http://localhost:3000/#/"
        },
        "blockWithoutEmailConfirm": true
    }
}

# class

  • Type: string
  • Default: ZXC\Modules\Auth\Auth
  • Description: Module class

# storageProvider

  • Type: string
  • Default: ZXC\Modules\Auth\Storages\AuthPgSqlStorage
  • Description: Provider for storage, this class will be using for working with user storage. Must implement ZXC\Modules\Auth\AuthStorage

# authTypeProvider

  • Type: string
  • Default: ZXC\\Modules\\Auth\\Providers\\AuthJwtTokenProvider
  • Description: Class for providing authentication, login and logout functionality

# remindPasswordInterval (minutes)

  • Type: integer
  • Default: 2 (minutes)
  • Description: Interval for requesting recovery password link

# remindPasswordLinkTemplate

  • Type: string
  • Default: /new/password/{code}/{login}
  • Description: Template where you can describe the URL address for password recovery. Placeholders {code} and {login} will be replaced by values. This link will be sent to user email

# remindPasswordEmailBody

  • Type: string
  • Default: {link}
  • Description: In this parameter you can describe email body template for password recovery. Placeholder {link} will be replaced by URL address described in parameter remindPasswordLinkTemplate

# remindPasswordLinkProvider

  • Type: string
  • Default: ZXC\\Modules\\Auth\\Providers\\AuthSendReminderLink
  • Description: Class for sending password recovery email

# authTypeProviderOptions

  • Type: object

  • Default: {}

  • Description: Options for class which described in parameter authTypeProvider will be passed into constructor. This options can be different for other providers

    # authTypeProviderOptions/secret

    • Type: string
    • Default: )(*&)HLKJHKJHIUG4FHGgg
    • Description: Secret key for JWT token sign

    # authTypeProviderOptions/alg

    • Type: string
    • Default: HS256
    • Description: Identifies which algorithm is used to generate the signature

    # authTypeProviderOptions/accessLifeTime

    • Type: string
    • Default: 14
    • Description: Identifies the expiration time on and after which the JWT must not be accepted for processing

    # authTypeProviderOptions/refreshLifetime

    • Type: string
    • Default: 200
    • Description: Identifies the expiration time on and after which the JWT (refresh) must not be accepted for processing

    # authTypeProviderOptions/tokenStorage

    • Type: string
    • Default: ZXC\Modules\Auth\Storages\AuthTokenStoragePgSql
    • Description: Storage for generated tokens

# email

  • Type: object

  • Default: {}

  • Description: Settings for email interactions

    # email/confirm

    • Type: bool
    • Default: true
    • Description: If true confirm email will be sent to user email

    # email/codeProvider

    • Type: string
    • Default: ZXC\Modules\Auth\Providers\AuthConfirmCodeProvider
    • Description: Class which will send code to user email

    # email/confirmUrlTemplate

    • Type: string
    • Default: /confirm/email/{code}/login/{login}
    • Description: Template for generating conformation email. Must be defined two placeholders {code} and {login}

    # email/body

    • Type: string
    • Default: <p> Welcome to the TaskView app! {link} </p>
    • Description: Template for email conformation body. Must be defined one placeholder {link}

    # email/redirectAfterConfirm

    • Type: string
    • Default: http://localhost:3000/#/
    • Description: URL address for redirecting after conformation

# blockWithoutEmailConfirm

  • Type: boolean
  • Default: true
  • Description: Block user until email will be confirmed

# How create your own module?

  • Create you class and implement IModule interface and user trait Module
 

 



 



 


class Tasks implements IModule
{
    use Module;

    protected array $config = [];

    public function init(array $options = [])
    {
        $this->config = $options;
    }
    //TODO your implementation
}
  • Add module to your config. Module can have next configuration
    • options.json - file describe main parameter for module class and own options for working
    • routes.json {optional} - if module functions can be accessed by HTTP you can add some routes and handlers
    • middlewares.json {optional} - define here route middlewares