Skip to content

Commit

Permalink
fix(channel-web): externalAuth token http headers
Browse files Browse the repository at this point in the history
  • Loading branch information
slvnperron committed Jul 30, 2019
1 parent 7e8f590 commit 41997df
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/guide/docs/advanced/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Here is an example configuration, [check the full configuration for more details

#### How to configure the Public Key

The public key can be added directly in the `botpress.config.json` file (on the same line). If you prefer to add the key in a file, remove the property `certificate`, and Botpress will load the key from `data/global/end_users_auth.key`
The public key can be added directly in the `botpress.config.json` file (on the same line). If you prefer to add the key in a file, remove the property `certificate`, and Botpress will load the key from `data/global/end_users_auth.pub`

#### How to create a new Key Pair

Expand Down
3 changes: 2 additions & 1 deletion modules/channel-web/src/views/lite/core/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default class WebchatApi {
this.axiosConfig = {
...this.axiosConfig,
headers: {
ExternalAuth: `Bearer ${externalAuthToken}`
ExternalAuth: `Bearer ${externalAuthToken}`,
'X-BP-ExternalAuth': `Bearer ${externalAuthToken}`
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/bp/core/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export default class HTTPServer {
})
}

@Memoize
@Memoize()
private async _getExternalAuthConfig(): Promise<ExternalAuthConfig | undefined> {
const botpressConfig = await this.configProvider.getBotpressConfig()
const config = botpressConfig.pro.externalAuth
Expand All @@ -394,8 +394,8 @@ export default class HTTPServer {
.error(`External User Auth: Couldn't open public key file /data/global/end_users_auth.pub`)
return undefined
}
} else if (config.publicKey.length < 256) {
this.logger.error(`External User Auth: The provided publicKey is invalid (too short)`)
} else if (config.publicKey.length < 128) {
this.logger.error(`External User Auth: The provided publicKey is invalid (too short). Min length is 128 chars.`)
return undefined
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/bp/core/services/dialog/janitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class DialogJanitor extends Janitor {
super(logger)
}

@Memoize
@Memoize()
private async getBotpresConfig(): Promise<BotpressConfig> {
return this.configProvider.getBotpressConfig()
}
Expand Down
2 changes: 1 addition & 1 deletion src/bp/core/services/logs/janitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class LogsJanitor extends Janitor {
super(logger)
}

@Memoize
@Memoize()
private async getBotpresConfig(): Promise<BotpressConfig> {
return this.configProvider.getBotpressConfig()
}
Expand Down
2 changes: 1 addition & 1 deletion src/bp/core/services/middleware/state-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class StateManager {
await this.sessionRepo.update(dialogSession)
}

@Memoize
@Memoize()
private async getBotpresConfig(): Promise<BotpressConfig> {
return this.configProvider.getBotpressConfig()
}
Expand Down

0 comments on commit 41997df

Please sign in to comment.