Skip to content

Tutorial:Authority verification logic

Psyche edited this page Oct 22, 2020 · 3 revisions

Authentication logic

In this chapter, you will learn:

  • authorization process
  • authorization services work

Process

ClientRequest -> AuthMiddleware -> AuthHandler -> Response auth result

How service work

  1. Request first go in middleware call "CheckAuthorization" method.
  2. In "CheckAuthorization" method extract the credentials at the location you defined.The credential location is Query/Header/Cookie.
  3. Check your defined authorization source sequence.Once the source returns the authorization status, the remaining sources will not be executed.

Default sequence:
AuthCenter -> Cache -> Database -> Default(Attribute)

  1. You need to define your own AuthHandler.You can define the "Cahce" and "Database" authorization behavior in the sequence.
  2. If your AuthHanler returns true, then your business code will execute normally.If false you need keep looking.
  3. In "AuthOptions.NonAccessParm" you can define no access time response code,response ContentType and response body.

Default http response:

Http Code: 200 
Body:
{
    "status":403,
    "msg":"No permission"
}

Clone this wiki locally