...
The following KRL declaration would bind the entire map associate associated with the twitter key to the variable my_key
:
...
Code Block | ||||
---|---|---|---|---|
| ||||
pre{ my_key = keys:twitter("consumer_secret"); } |
Key Modules
KRL
...
provides
...
a
...
mechanism
...
for
...
accessing keys that are stored in modules. A key module uses the pragma provide keys
(or provides keys
) to specify which previously defined keys should be made available to which rulesets. For example, is rulesets a16x175
and b16x77
require the use of a set of Dropbox keys, the following module could provide those keys specifically to the named rulesets:
Code Block | ||||
---|---|---|---|---|
| ||||
ruleset b16x5 { meta { name "Dropbox keys" description << These are the keys for testing. This file should not be on a publicly available URL >> key dropbox { "app_key" : "<app key here>", "app_secret" : "<app secret here>" } provide keys dropbox to a16x175, b16x77 } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
ruleset a16x175 { meta { name "Dropbox module test" use module b16x5 use module b16x0 alias dropbox with app_key = keys:dropbox('"app_key'") and app_secret = keys:dropbox('"app_secret'") } |
This example loads the keys in module b16x5
and then uses them to configure module b16x0
.
...
When using key modules as shown above, you will need your any key rulesets to be available on a URL so that you can register them with the rules engine. Otherwise they will not be available for use by other rulesets. The URL should be protected so that it is they are not publicly viewable. For example, the ruleset could be on a WebDAV server with an appropriately formatted BASIC AUTH URL or in a private GitHub repositoryprivate repository.
If you're hosting on AWS S3, be sure to check the permissions of the file so that it is not writable or readable by anyone other than authorized users. You will need to create a pre-signed AWS URL. There are ways of doing this with various programming languages. I've found this project for signing AWS URLs with a Bash script to be quite useful.
...