Skip to content

Commit

Permalink
fix(logs): remove now unneeded logs secret key
Browse files Browse the repository at this point in the history
  • Loading branch information
emirotin committed Jul 10, 2018
1 parent 3278e04 commit 3c57c06
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
13 changes: 1 addition & 12 deletions packages/core/botpress/src/server/secured.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import _ from 'lodash'
import nanoid from 'nanoid'
import multer from 'multer'
import moment from 'moment'

import util from '../util'

let logsSecret = nanoid()

module.exports = (bp, app) => {
// modules

Expand Down Expand Up @@ -98,20 +95,12 @@ module.exports = (bp, app) => {
})
})

app.secure('read', 'bot.logs').get('/api/logs/key', (req, res) => {
res.send({ secret: logsSecret })
})

app.secure('read', 'bot.logs.archive').get('/api/logs/archive/:key', (req, res) => {
app.secure('read', 'bot.logs.archive').get('/api/logs/archive', (req, res) => {
bp.stats.track('api', 'logs', 'archive')
if (req.params.key !== logsSecret) {
return res.sendStatus(403)
}

bp.logger
.queryDb(null, 'asc')
.then(results => {
logsSecret = nanoid()
res.setHeader('Content-type', 'text/plain')
res.setHeader('Content-disposition', 'attachment; filename=logs.txt')
res.send(
Expand Down
7 changes: 1 addition & 6 deletions packages/core/botpress/src/web/views/Logs/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class LoggerView extends Component {

componentDidMount() {
if (!this.state.logs) {
this.getArchiveKey()
this.queryLogs()
this.refreshInterval = setInterval(this.queryLogs, 1000)
}
Expand Down Expand Up @@ -62,10 +61,6 @@ class LoggerView extends Component {
return <div style={{ marginTop: '20px' }} className="whirl traditional" />
}

getArchiveKey() {
axios.get('/api/logs/key').then(({ data }) => this.setState({ archiveUrl: '/api/logs/archive/' + data.secret }))
}

queryLogs = () => {
axios
.get('/api/logs', {
Expand Down Expand Up @@ -94,7 +89,7 @@ class LoggerView extends Component {

downloadArchive = () => {
axios({
url: this.state.archiveUrl,
url: '/api/logs/archive/',
method: 'GET',
responseType: 'blob'
}).then(response => {
Expand Down

0 comments on commit 3c57c06

Please sign in to comment.