diff --git a/README.md b/README.md index 5110daa3..eb009fc5 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ REST Client allows you to send HTTP request and view the response in Visual Stud + `{{$processEnv [%]envVarName}}` + `{{$dotenv [%]variableName}}` + `{{$aadToken [new] [public|cn|de|us|ppe] [] [aud:]}}` - + `{{$oidcAccessToken [new] [] [] [authorizeEndpoint:] [callbackPort:] [authorizeEndpoint:] [tokenEndpoint:] [scopes:] [audience:]}}` - Easily create/update/delete environments and environment variables in setting file - File variables can reference both custom and system variables - Support environment switch @@ -601,12 +601,14 @@ System variables provide a pre-defined set of variables that can be used in any `clientId:`: Optional. Identifier of the application registration to use to obtain the token. Default uses an application registration created specifically for this plugin. -* `{{$oidcAccessToken [new] [] [] [authorizeEndpoint:] [callbackDomain:] [callbackPort:] [authorizeEndpoint:] [tokenEndpoint:] [scopes:] [audience:]}}`: Add an Oidc Identity Server token based on the following options (must be specified in order): `new`: Optional. Specify `new` to force re-authentication and get a new token for the client. Default: Reuse previous token for clientId from an in-memory cache. Expired tokens are refreshed automatically. (Restart Visual Studio Code to clear the cache.) `clientId:`: Optional. Identifier of the application registration to use to obtain the token. + `callbackDomain:`: Optional. If set, redirect URI will be set to `https://:`. Defaults to `localhost` resulting in `http://localhost:`. + `callbackPort:`: Optional. Port to use for the local callback server. Default: 7777 (random port). `authorizeEndpoint:`: The authorization endpoint to use. @@ -615,7 +617,7 @@ System variables provide a pre-defined set of variables that can be used in any `scopes:`: Optional. Comma delimited list of scopes that must have consent to allow the call to be successful. - `audience:`: Optional. + `audience:`: Optional. When set, will be passed in the query as `audience` parameter. * `{{$guid}}`: Add a RFC 4122 v4 UUID * `{{$processEnv [%]envVarName}}`: Allows the resolution of a local machine environment variable to a string value. A typical use case is for secret keys that you don't want to commit to source control. diff --git a/src/utils/httpVariableProviders/systemVariableProvider.ts b/src/utils/httpVariableProviders/systemVariableProvider.ts index bfe380c9..7d2e1023 100644 --- a/src/utils/httpVariableProviders/systemVariableProvider.ts +++ b/src/utils/httpVariableProviders/systemVariableProvider.ts @@ -39,7 +39,7 @@ export class SystemVariableProvider implements HttpVariableProvider { private readonly requestUrlRegex: RegExp = /^(?:[^\s]+\s+)([^:]*:\/\/\/?[^/\s]*\/?)/; private readonly aadRegex: RegExp = new RegExp(`\\s*\\${Constants.AzureActiveDirectoryVariableName}(\\s+(${Constants.AzureActiveDirectoryForceNewOption}))?(\\s+(ppe|public|cn|de|us))?(\\s+([^\\.]+\\.[^\\}\\s]+|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}))?(\\s+aud:([^\\.]+\\.[^\\}\\s]+|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}))?\\s*`); - private readonly oidcRegex: RegExp = new RegExp(`\\s*(\\${Constants.OidcVariableName})(?:\\s+(${Constants.OIdcForceNewOption}))?(?:\\s*clientId:([\\w|.|:|/|_|-]+))?(?:\\s*issuer:([\\w|.|:|/]+))?(?:\\s*callbackDomain:([\\w|.|:|/|_|-]+))?(?:\\s*callbackPort:([\\w|_]+))?(?:\\s*authorizeEndpoint:([\\w|.|:|/|_|-]+))?(?:\\s*tokenEndpoint:([\\w|.|:|/|_|-]+))?(?:\\s*scopes:([\\w|.|:|/|_|-]+))?(?:\\s*audience:([\\w|.|:|/|_|-]+))?`); + private readonly oidcRegex: RegExp = new RegExp(`\\s*(\\${Constants.OidcVariableName})(?:\\s+(${Constants.OIdcForceNewOption}))?(?:\\s*clientId:([\\w.:/_\\-]+))?(?:\\s*issuer:([\\w.:/]+))?(?:\\s*callbackDomain:([\\w.:/_\\-]+))?(?:\\s*callbackPort:([\\w_]+))?(?:\\s*authorizeEndpoint:([\\w.:/_\\-]+))?(?:\\s*tokenEndpoint:([\\w.:/_\\-]+))?(?:\\s*scopes:([\\w.:/_\\-,]+))?(?:\\s*audience:([\\w.:/_\\-]+))?`); private readonly innerSettingsEnvironmentVariableProvider: EnvironmentVariableProvider = EnvironmentVariableProvider.Instance; private static _instance: SystemVariableProvider;