Skip to content

Commit

Permalink
additional metadata for consumer (issue Kong#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyiss committed Nov 10, 2015
1 parent 9aeb778 commit d978668
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions kong/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ return {
UPSTREAM_LATENCY = "X-Kong-Upstream-Latency",
CONSUMER_ID = "X-Consumer-ID",
CONSUMER_CUSTOM_ID = "X-Consumer-Custom-ID",
CONSUMER_CUSTOM_DATA = "X-Consumer-Custom-Data",
CONSUMER_USERNAME = "X-Consumer-Username",
CREDENTIAL_USERNAME = "X-Credential-Username",
RATELIMIT_LIMIT = "X-RateLimit-Limit",
Expand Down
1 change: 1 addition & 0 deletions kong/dao/cassandra/schema/migrations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ local Migrations = {
CREATE TABLE IF NOT EXISTS consumers(
id uuid,
custom_id text,
custom_data text,
username text,
created_at timestamp,
PRIMARY KEY (id)
Expand Down
1 change: 1 addition & 0 deletions kong/dao/schemas/consumers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ return {
id = { type = "id", dao_insert_value = true },
created_at = { type = "timestamp", dao_insert_value = true },
custom_id = { type = "string", unique = true, queryable = true, func = check_custom_id_and_username },
custom_data = { type = "text" },
username = { type = "string", unique = true, queryable = true, func = check_custom_id_and_username }
}
}
1 change: 1 addition & 0 deletions kong/plugins/basic-auth/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ function _M.execute(conf)

ngx.req.set_header(constants.HEADERS.CONSUMER_ID, consumer.id)
ngx.req.set_header(constants.HEADERS.CONSUMER_CUSTOM_ID, consumer.custom_id)
ngx.req.set_header(constants.HEADERS.CONSUMER_CUSTOM_DATA, consumer.custom_data)
ngx.req.set_header(constants.HEADERS.CONSUMER_USERNAME, consumer.username)
ngx.req.set_header(constants.HEADERS.CREDENTIAL_USERNAME, credential.username)
ngx.ctx.authenticated_credential = credential
Expand Down
1 change: 1 addition & 0 deletions kong/plugins/hmac-auth/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ function _M.execute(conf)

ngx_set_header(constants.HEADERS.CONSUMER_ID, consumer.id)
ngx_set_header(constants.HEADERS.CONSUMER_CUSTOM_ID, consumer.custom_id)
ngx.req.set_header(constants.HEADERS.CONSUMER_CUSTOM_DATA, consumer.custom_data)
ngx_set_header(constants.HEADERS.CONSUMER_USERNAME, consumer.username)
ngx.req.set_header(constants.HEADERS.CREDENTIAL_USERNAME, credential.username)
ngx.ctx.authenticated_credential = credential
Expand Down
1 change: 1 addition & 0 deletions kong/plugins/jwt/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function _M.execute(conf)

ngx.req.set_header(constants.HEADERS.CONSUMER_ID, consumer.id)
ngx.req.set_header(constants.HEADERS.CONSUMER_CUSTOM_ID, consumer.custom_id)
ngx.req.set_header(constants.HEADERS.CONSUMER_CUSTOM_DATA, consumer.custom_data)
ngx.req.set_header(constants.HEADERS.CONSUMER_USERNAME, consumer.username)
ngx.ctx.authenticated_credential = jwt_secret
end
Expand Down
1 change: 1 addition & 0 deletions kong/plugins/key-auth/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function _M.execute(conf)

ngx.req.set_header(constants.HEADERS.CONSUMER_ID, consumer.id)
ngx.req.set_header(constants.HEADERS.CONSUMER_CUSTOM_ID, consumer.custom_id)
ngx.req.set_header(constants.HEADERS.CONSUMER_CUSTOM_DATA, consumer.custom_data)
ngx.req.set_header(constants.HEADERS.CONSUMER_USERNAME, consumer.username)
ngx.ctx.authenticated_credential = credential
end
Expand Down

0 comments on commit d978668

Please sign in to comment.