change subscriptionKey -> authoringKey

This commit is contained in:
Tom Laird-McConnell 2018-03-21 17:19:37 -07:00
Родитель 128dbca890
Коммит 886facadf0
6 изменённых файлов: 37 добавлений и 38 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -286,3 +286,5 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs
LUIS/.luisrc
LUIS/.luisrc

Просмотреть файл

@ -61,10 +61,10 @@ async function runProgram() {
async function initializeConfig() {
process.stdout.write(chalk.cyan.bold('\nThis util will walk you through creating a .luisrc file\n\nPress ^C at any time to quit.\n\n'));
const questions = [
'Subscription key: ',
'Region: ',
'App ID: ',
'Version ID: '
'What is your LUIS App ID: ',
'What is your LUIS Authoring key (from luis.ai portal User Settings page): ',
'What is your LUIS Version ID (Default: 0.1): ',
'What region [(Default) westus, westeurope, australiaeast] : ',
];
const prompt = readline.createInterface({
@ -82,10 +82,10 @@ async function initializeConfig() {
answers.push(answer);
}
const [subscriptionKey, location, appId, versionId] = answers;
const [appId, authoringKey, versionId, location] = answers;
const config = Object.assign({}, {
subscriptionKey,
appId,
authoringKey,
versionId,
endpointBasePath: `https://${location}.api.cognitive.microsoft.com/luis/api/v2.0`,
});
@ -125,11 +125,11 @@ async function getFileInput(args) {
* @returns {Promise<*>}
*/
async function composeConfig() {
const {LUIS_APP_ID, LUIS_SUBSCRIPTION_KEY, LUIS_VERSION_ID, LUIS_ENDPOINT_BASE_PATH} = process.env;
const {LUIS_APP_ID, LUIS_ACCESS_KEY, LUIS_VERSION_ID, LUIS_ENDPOINT_BASE_PATH} = process.env;
const {
appId: args_appId,
subscriptionKey: args_subscriptionKey,
authoringKey: args_authoringKey,
versionId: args_versionId,
endpointBasePath: args_endpointBasePath
} = args;
@ -144,7 +144,7 @@ async function composeConfig() {
} finally {
config = {
appId: (args_appId || luisrcJson.appId || LUIS_APP_ID),
subscriptionKey: (args_subscriptionKey || luisrcJson.subscriptionKey || LUIS_SUBSCRIPTION_KEY),
authoringKey: (args_authoringKey || luisrcJson.authoringKey || LUIS_ACCESS_KEY),
versionId: (args_versionId || luisrcJson.versionId || LUIS_VERSION_ID),
endpointBasePath: (args_endpointBasePath || luisrcJson.endpointBasePath || LUIS_ENDPOINT_BASE_PATH)
};
@ -160,12 +160,12 @@ async function composeConfig() {
* @param {*} config The config object to validate
*/
function validateConfig(config) {
const {versionId, appId, subscriptionKey, endpointBasePath} = config;
const {versionId, appId, authoringKey, endpointBasePath} = config;
const messageTail = `is missing from the configuration.\n\nDid you run ${chalk.cyan.bold('luis --init')} yet?`;
assert(typeof versionId === 'string', `The versionId ${messageTail}`);
assert(typeof appId === 'string', `The appId ${messageTail}`);
assert(typeof subscriptionKey === 'string', `The subscriptionKey ${messageTail}`);
assert(typeof authoringKey === 'string', `The authoringKey ${messageTail}`);
assert(typeof versionId === 'string', `The versionId ${messageTail}`);
assert(typeof endpointBasePath === 'string', `The endpointBasePath ${messageTail}`);
}

Просмотреть файл

@ -61,7 +61,7 @@ class ServiceBase {
get commonHeaders() {
return {
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': ServiceBase.config.subscriptionKey
'Ocp-Apim-Subscription-Key': ServiceBase.config.authoringKey
};
}
}
@ -85,8 +85,8 @@ ServiceBase.validateParams = function (tokenizedUrl, params) {
};
/**
* @type {*} The configuration object containing
* the endpointBasePath, appId, versionId and subscriptionKey properties.
* the endpointBasePath, appId, versionId and authoringKey properties.
*/
ServiceBase.config = {endpointBasePath: '', appId: '', versionId: '', subscriptionKey: ''};
ServiceBase.config = {endpointBasePath: '', appId: '', versionId: '', authoringKey: ''};
module.exports = {ServiceBase};

Просмотреть файл

@ -94,9 +94,9 @@ function getGeneralHelpContents() {
{
head: 'Configuration and Overrides:',
table: [
['--appId', 'Specifies the application id. Overrides the .luisrc value and the LUIS_APP_ID environment variable.'],
['--appId', 'Specifies the public LUIS application id. Overrides the .luisrc value and the LUIS_APP_ID environment variable.'],
['--authoringKey', 'Specifies the LUIS authoring key (from luis.ai portal user settings page). Overrides the .luisrc value and the LUIS_AUTHORING_KEY environment variable.'],
['--versionId', 'Specifies the version id. Overrides the .luisrc value and the LUIS_VERSION_ID environment variable.'],
['--subscriptionKey', 'Specifies the subscription key. Overrides the .luisrc value and the LUIS_SUBSCRIPTION_LEY environment variable.'],
['--endpointBasePath', 'Specifies the base URI for all requests. Overrides the .luisrc value and the LUIS_ENDPOINT_BASE_PATH environment variable.'],
]
},

Просмотреть файл

@ -28,13 +28,13 @@ appsService.getApplicationsList({take: 5}).then(apps => {
## Configuration
A configuration object is required to provide the endpoint base path, app ID, version ID and the
subscription key to each outbound call. There are 3 ways to provide this information to the cli
authoring key to each outbound call. There are 3 ways to provide this information to the cli
1. As a `.luisrc` file in the cwd.
The json format for the `.luisrc` file is:
```json
{
"subscriptionKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"authoringKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"versionId": "x.x.xx",
"endpointBasePath": "https://xxxxxx.api.cognitive.microsoft.com/luis/api/v2.0"
}
@ -42,15 +42,15 @@ The json format for the `.luisrc` file is:
The cli has a utility command that walks through the creation of this file:
`luis --init`
or it can be created manually.
2. As arguments to the cli. `--subscriptionKey <string> --appId <string> --versionId <string> --endpointBasePath <string>`
3. As environment variables. `LUIS_APP_ID, LUIS_SUBSCRIPTION_KEY, LUIS_VERSION_ID, LUIS_ENDPOINT_BASE_PATH`
2. As arguments to the cli. `--appId <string> --versionId <string> --authoringKey <string> --endpointBasePath <string>`
3. As environment variables. `LUIS_APP_ID, LUIS_VERSION_ID, LUIS_AUTHORING_KEY, LUIS_ENDPOINT_BASE_PATH`
The cli will first look for these named configuration variables in the arguments list, then inside the `.luisrc` file,
then fallback to environment variables.
### Securing Your Key
To better secure your subscription key, it's recommended to omit the key from the `.luisrc`
file and instead pass it in to the `--subscriptionKey` argument or store it as the `LUIS_SUBSCRIPTION_KEY`
### Securing Your Access Key
To better secure your access key, it's recommended to omit the key from the `.luisrc`
file and instead pass it in to the `--authoringKey` argument or store it as the `LUIS_AUTHORING_KEY`
environment variable. If security is not a concern for your particular case, all configuration items
can be stored in the `.luisrc` for convenience.
@ -63,8 +63,8 @@ This configuration object is provided as a static property on the `ServicecBase`
```js
import {ServiceBase} from 'luis/lib/serviceBase';
ServiceBase.config = {
"subscriptionKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"authoringKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"versionId": "x.x.xx",
"endpointBasePath": "https://xxxxxx.api.cognitive.microsoft.com/luis/api/v2.0"
}
@ -102,9 +102,6 @@ Arguments may be one or more of the following:
| :-----------------------------------------|------------------------------------------------------------------|
| --appId | Specifies the application id. This can optionally be specified in the .luisrc |
| --versionId | Specifies the version id. This can optionally be specified in the .luisrc |
| --in <path> | Specifies the input file path. Applicable for create, update and patch actions |
| --skip <integer> | Specifies the number of records to skip. Applicable for the list action only |
| --take <integer> | Specifies the number of records to take. Applicable for the list action only |
Global Arguments:

Просмотреть файл

@ -34,23 +34,23 @@ describe('The LUIS cli --init argument', () => {
break;
case 2:
assert(message === 'Subscription key: ');
assert(message.indexOf('App') > 0);
luisProcess.stdin.write(`${appId}\r`);
break;
case 3:
assert(message.indexOf('Key') > 0);
luisProcess.stdin.write('abc123\r');
break;
case 3:
assert(message === 'Region: ');
luisProcess.stdin.write(`${location}\r`);
break;
case 4:
assert(message === 'App ID: ');
luisProcess.stdin.write(`${appId}\r`);
assert(message.indexOf('Version') > 0);
luisProcess.stdin.write(`${versionId}\r`);
break;
case 5:
assert(message === 'Version ID: ');
luisProcess.stdin.write(`${versionId}\r`);
assert(message.indexOf('Region: ') > 0);
luisProcess.stdin.write(`${location}\r`);
break;
case 6: