
# 创建自定义认证
#### 功能介绍
创建自定义认证
#### URI
HTTP/HTTPS请求方法以及URI如下表所示。
表1HTTP/HTTPS请求方法以及URI 
| 请求方法 | URI                     |
|:---|:---|
| POST | /v1.0/apigw/authorizers |
   
#### 请求消息
表2参数说明 
| 名称              | 是否必选 | 类型      | 说明                                                                                                                                                                                                                                                                                                                                                                                                                      |
|:---|:---|:---|:---|
| name            | 是    | String  | 自定义认证的名称。 长度为3 \~ 64位的字符串，字符串由中文、英文字母、数字、"_"组成，且只能以英文或中文开头。                                                                                                                                                                                                                                                                                                    |
| type            | 是    | String  | 自定义认证类型： - FRONTEND：前端  - BACKEND：后端   |
| authorizer_type | 是    | String  | 只能为：FUNC                                                                                                                                                                                                                                                                                                                                                                                                                |
| authorizer_uri  | 是    | String  | 函数urn                                                                                                                                                                                                                                                                                                                                                                                                                   |
| identities      | 否    | List    | 认证来源                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ttl             | 否    | Integer | 缓存时间                                                                                                                                                                                                                                                                                                                                                                                                                    |
| user_data       | 否    | String  | 用户数据                                                                                                                                                                                                                                                                                                                                                                                                                    |
   
表3identities参数说明 
| 名称       | 是否必选 | 类型     | 说明                                                                                                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|:---|
| name     | 是    | String | 参数名称                                                                                                                                                                                                                                                                                                                                                                                                                      |
| location | 是    | String | 参数位置： - HEADER：头  - QUERY：query   |
   
请求消息样例：
```
{
    "name":"Authorizer_9dlh",
    "type":"FRONTEND",
    "authorizer_type":"FUNC",
    "authorizer_uri":"urn:fss:regionexample:dbb5762c88f045c6a1427a952bcae284:function:default:test111",
    "ttl":10,
    "user_data":"aaaa",
    "identities":[
        {
            "name":"Authorization",
            "location":"HEADER"
        }
    ]
}
```
#### 响应消息
表4参数说明 
| 名称              | 类型            | 说明                                                                                                                                                                                                                                                                                                                                                                                                                       |
|:---|:---|:---|
| id              | String        | 编号                                                                                                                                                                                                                                                                                                                                                                                                                       |
| name            | String        | 自定义认证的名称                                                                                                                                                                                                                                                                                                                                                                                                                 |
| type            |  String | 自定义认证类型： - FRONTEND：前端  - BACKEND：后端   |
| authorizer_type | String        | 只能为：FUNC                                                                                                                                                                                                                                                                                                                                                                                                                 |
| authorizer_uri  | String        | 函数urn                                                                                                                                                                                                                                                                                                                                                                                                                    |
| identities      | Array         | 认证来源                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ttl             | Integer       | 缓存时间                                                                                                                                                                                                                                                                                                                                                                                                                     |
| user_data       | String        | 用户数据                                                                                                                                                                                                                                                                                                                                                                                                                     |
| create_time     | Time          | 创建时间                                                                                                                                                                                                                                                                                                                                                                                                                     |
   
表5identities参数说明 
| 名称       | 类型     | 说明                                                                                                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|
| name     | String | 参数名称                                                                                                                                                                                                                                                                                                                                                                                                                      |
| location | String | 参数位置： - HEADER：头  - QUERY：query   |
   
响应消息样例：
```
{
    "name":"Authorizer_9dlh",
    "type":"FRONTEND",
    "authorizer_type":"FUNC",
    "authorizer_uri":"urn:fss:regionexample:dbb5762c88f045c6a1427a952bcae284:function:default:test111",
    "identities":[
        {
            "name":"Authorization",
            "location":"HEADER",
        }
    ],
    "ttl":10,
    "user_data":"aaaa",
    "id":"7345e3fe4047491ebd8ecb0acd665a4c",
    "create_time":"2020-01-19T11:48:56.576611862Z"
}
```
#### 状态码
表6返回消息说明 
| 状态码 | 说明                    |
|:---|:---|
| 201 | Created               |
| 400 | Bad Request           |
| 401 | Unauthorized          |
| 403 | Forbidden             |
| 500 | Server Internal Error |
   
