-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
Copy pathdaos.lua
31 lines (30 loc) · 1.07 KB
/
daos.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local typedefs = require "kong.db.schema.typedefs"
local crypto = require "kong.plugins.basic-auth.crypto"
return {
{
name = "basicauth_credentials",
primary_key = { "id" },
cache_key = { "username" },
endpoint_key = "username",
workspaceable = true,
admin_api_name = "basic-auths",
admin_api_nested_name = "basic-auth",
fields = {
{ id = typedefs.uuid },
{ created_at = typedefs.auto_timestamp_s },
{ consumer = { type = "foreign", reference = "consumers", required = true, on_delete = "cascade" }, },
{ username = { type = "string", required = true, unique = true }, },
{ password = { type = "string", required = true, encrypted = true }, }, -- encrypted = true is a Kong Enterprise Exclusive feature, it does nothing in Kong CE
{ tags = typedefs.tags },
},
transformations = {
{
input = { "password" },
needs = { "consumer.id" },
on_write = function(password, consumer_id)
return { password = crypto.hash(consumer_id, password) }
end,
},
},
},
}