1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-19 10:00:06 +00:00

feat(create-context): add list of authorized users

This commit is contained in:
Krishna Acondy
2020-09-06 21:32:48 +01:00
parent fc1d54d105
commit 26c8946fd5
2 changed files with 24 additions and 14 deletions

View File

@@ -201,6 +201,7 @@ export class SASViyaApiClient {
launchContextName: string, launchContextName: string,
sharedAccountId: string, sharedAccountId: string,
autoExecLines: string, autoExecLines: string,
authorizedUsers: string[],
accessToken?: string accessToken?: string
) { ) {
if (!contextName) { if (!contextName) {
@@ -223,23 +224,30 @@ export class SASViyaApiClient {
headers.Authorization = `Bearer ${accessToken}` headers.Authorization = `Bearer ${accessToken}`
} }
const requestBody: any = {
name: contextName,
environment: {
autoExecLines: autoExecLines || ''
},
launchContext: {
contextName: launchContextName
},
attributes: {
reuseServerProcesses: true,
runServerAs: sharedAccountId
}
}
if (authorizedUsers && authorizedUsers.length) {
requestBody['authorizedUsers'] = authorizedUsers
} else {
requestBody['authorizeAllAuthenticatedUsers'] = true
}
const createContextRequest: RequestInit = { const createContextRequest: RequestInit = {
method: 'POST', method: 'POST',
headers, headers,
body: JSON.stringify({ body: JSON.stringify(requestBody)
name: contextName,
environment: {
autoExecLines: autoExecLines || ''
},
launchContext: {
contextName: launchContextName
},
authorizeAllAuthenticatedUsers: true,
attributes: {
reuseServerProcesses: true,
runServerAs: sharedAccountId
}
})
} }
const { result: context } = await this.request<Context>( const { result: context } = await this.request<Context>(

View File

@@ -112,6 +112,7 @@ export default class SASjs {
launchContextName: string, launchContextName: string,
sharedAccountId: string, sharedAccountId: string,
autoExecLines: string, autoExecLines: string,
authorizedUsers: string[],
accessToken: string accessToken: string
) { ) {
if (this.sasjsConfig.serverType !== ServerType.SASViya) { if (this.sasjsConfig.serverType !== ServerType.SASViya) {
@@ -122,6 +123,7 @@ export default class SASjs {
launchContextName, launchContextName,
sharedAccountId, sharedAccountId,
autoExecLines, autoExecLines,
authorizedUsers,
accessToken accessToken
) )
} }