How to get service_id/route_id/consumer_id in custom plugin(access method)?

How to get service_id/route_id/consumer_id in custom plugin(access method)?

ngx.ctx.service.id
ngx.ctx.route.id
ngx.ctx.authenticated_credential.consumer_id

Should be the vars you need. Maybe the SDK released here shortly will provide other ways of referencing as well.

Also:
ngx.ctx.authenticated_consumer

Some plugins, e.g. our EE OpenID Connect plugin may set:
ngx.ctx.authenticated_credential

with or without .consumer_id, and still allow say rate-limiting by arbitrary claim in some token (such as access token).

We look forward to provide official plugin API for this, but for now, those are your options. Authentication plugins set these consumer/credential context values.