1.0.41 • Published 4 years ago

@hilma/auth-server v1.0.41

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

Hilma Auth (Server)

Hilma Auth Server side is build over loopback 3, Providing you usefull extentions to the basic loopback auth. (Previously named auth, tools, supermodel)

Installation

Go into your project, make sure you are inside the server folder (root folder, mostly):

via NPM

  npm install @hilma/auth-server

via Submodule

  git submodule add https://github.com/hilma-tech/hilma-auth-server.git auth

Important: Make sure you add to model-config.json the path to the module.

Introduction

Hilma Auth Server is divided to 3 main things:

roleAccessConfig

In order to use custom components and dhp for each role, you'll need to add to your server/config.json something like this:

"roleAccessConfig": {
  "ADMIN": {
    "comps": [
      "AdminMain"
    ],
    "defaultHomePage": "AdminMain"
  },
  "TRAINER": {
    "comps": [
      "TrainerMain"
    ],
    "defaultHomePage": "TrainerMain"
  },
  "COACH": {
    "comps": [
      "CoachHome"
    ],
    "defaultHomePage": "CoachHome"
  }
}

Mixins

Extended User

You can add the Extended User mixin to your user model, like that:

{
  "name": "Customer",
  "base": "User",
  "mixins": {
    "ExtendedUser": true,
   }
 }
What this mixins adds to your model (basic addons)?

When you activate the mixins, it gives you the following addons: | Addone | Explenation | | ------ | ------ | | Created, Modified | Create a 'Created' and 'Modified' properties on your model. | | RoleMapping | HasOne Relation to role-mapping model. | | After login | Gives you kl, klos, access-token cookies after login. | | Authenticate (func) | checks if the requested user has a valid AccessToken. | | deleteUserItems (func) | Delete the user Items after logout |

More Addones

If you want, you can allow more options to this mixin.

  • Disable Email

    If true, disable all Email related requirements - you won't need to provide an email while login or register, etc. Accepts a boolean (default false) Example:

         "ExtendedUser": {
             "DisableEmail": true,
          }
  • Default Max Age

    Define for how long the cookies are going to last (milliseconds). Accepts a number. Example:

         "ExtendedUser": {
             "DefaultMaxAge": 31556952000,
          }

    ( 31556952000 = one year in ms )

  • ManagedPasswords
  • Optional functions to manage user's password for security reasons. | property | Explenation | Default | type | ------ | ------ | ------ | ------ | | PreviousPasswords | Saves each user's 5 last passwords (encrypted) on a table name "Stop". Won't let user change their password to one of the previous ones. | false | boolean | ForceResetPassword | Force the user to change password after time specified. if "true" - uses the default value. Otherwise, use the number provided. | 6 months in ms (15552000000) | boolean\ number (ms)

    Example:

         "ExtendedUser": {
            "ManagedPasswords": {
             "PreviousPasswords": true,
             "ForceResetPassword": 93434223344
            }
          }
  • AccessLogger

    Won't let user log in if they fail to log in X times. | property | Explenation | Default | ------ | ------ | ------ | | BlockCount | The number of tries a user have before they been block. | 5 | BlockTime | The time the user has to wait before trying to log in again (milliseconds) | 600000 Example:

         "ExtendedUser": {
             "AccessLogger": {
                "BlockCount": 3,
                "BlockTime": 50000
             },
          }
  • ResetPassword

    Reset Password option will let the user reset his password through an email. | property | Explenation | Default | ------ | ------ | ------ | | Subject | The subject of the mail sent to the user. | Password Reset | TextStart | The text to begin the mail with. | Click | Click | The href text | here | TextEnd | The text to ends the mail with. | to reset your password

    Example:

         "ExtendedUser": {
           "ResetPassword": {
             "Subject": "איפוס ססמה בתן כתף",
             "TextStart": "שלום, על מנת לאפס ססמה לחץ",
             "Click": "ממש פה!!!",
             "TextEnd": "יום מקסים שיהיה לכם"
            },
          }
  • EmailVarification

    Reset Password option will let the user reset his password through an email. | property | Explenation | Default | ------ | ------ | ------ | | Subject | The subject of the mail sent to the user. | Verify Registration | TextStart | The text to begin the mail with. | Click | Click | The href text | here | TextEnd | The text to ends the mail with. | to verify your email

    Example:

         "ExtendedUser": {
              "EmailVarification": {
                "Subject": "תן כתף - אימות אימייל",
                "TextStart": "שלום, על מנת לאמת את אימיילך לחץ",
                "Click": "כאן!!!!!",
                "TextEnd": "יום מבורך"
              }
          }
Example of all ExtendedUser mixins' options:
{
 "mixins": {
    "ExtendedUser": {
      "DefaultMaxAge": 3545344424, 
      "DisableEmail": true,
      "ManagedPasswords": {
         "PreviousPasswords": true,
         "ForceResetPassword": 93434223344
       },
      "AccessLogger": {
        "BlockCount": 3,
        "BlockTime": 50000
      },
      "ResetPassword": {
        "Subject": "איפוס ססמה בתן כתף",
        "TextStart": "שלום, על מנת לאפס ססמה לחץ",
        "Click": "ממש פה!!!",
        "TextEnd": "יום מקסים שיהיה לכם"
      },
      "EmailVarification": {
        "Subject": "תן כתף - אימות אימייל",
        "TextStart": "שלום, על מנת לאמת את אימיילך לחץ",
        "Click": "כאן!!!!!",
        "TextEnd": "יום מבורך"
      }
    }
  }
}

Delete Relations

This mixin deletes somtehing and everything related to it. It create a function to the model (Model.deleteRelationalById), which accept an Id of the user.

Tools

Discover Models

Time Calcs

Validate Tools

License

MIT

1.0.41

4 years ago

1.0.40

4 years ago

1.0.39

4 years ago

1.0.38

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.33

4 years ago

1.0.34

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.30

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago