Skip to content

Commit 577b7b6

Browse files
authored
Merge pull request #66 from craftship/move-to-auth-header
Use authorization header / insights custom authorizer
2 parents 275ae90 + caa9bfa commit 577b7b6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/adapters/logger.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default class Logger {
1212
method: 'POST',
1313
headers: {
1414
'Content-Type': 'application/json',
15+
Authorization: `Bearer ${this.credentials.clientId}:${this.credentials.secret}`,
1516
},
1617
body: JSON.stringify(json),
1718
});
@@ -21,7 +22,6 @@ export default class Logger {
2122
async error(user, { stack, message }) {
2223
const json = {
2324
user,
24-
credentials: this.credentials,
2525
timestamp: new Date(),
2626
level: 'error',
2727
namespace: `error:${this.namespace}`,
@@ -37,7 +37,6 @@ export default class Logger {
3737
async info(user, message) {
3838
const json = {
3939
user,
40-
credentials: this.credentials,
4140
timestamp: new Date(),
4241
level: 'info',
4342
namespace: `info:${this.namespace}`,

test/adapters/logger.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ describe('Logger', () => {
3232
method: 'POST',
3333
headers: {
3434
'Content-Type': 'application/json',
35+
Authorization: 'Bearer foo-client-id:bar-secret',
3536
},
36-
body: '{"user":{"name":"foo","avatar":"https://example.com"},"credentials":{"clientId":"foo-client-id","secret":"bar-secret"},"timestamp":"1970-01-01T00:00:00.000Z","level":"info","namespace":"info:foo:bar","body":{"foo":"bar"}}',
37+
body: '{"user":{"name":"foo","avatar":"https://example.com"},"timestamp":"1970-01-01T00:00:00.000Z","level":"info","namespace":"info:foo:bar","body":{"foo":"bar"}}',
3738
}));
3839
});
3940
});
@@ -54,8 +55,9 @@ describe('Logger', () => {
5455
method: 'POST',
5556
headers: {
5657
'Content-Type': 'application/json',
58+
Authorization: 'Bearer foo-client-id:bar-secret',
5759
},
58-
body: '{"user":{"name":"foo","avatar":"https://example.com"},"credentials":{"clientId":"foo-client-id","secret":"bar-secret"},"timestamp":"1970-01-01T00:00:00.000Z","level":"error","namespace":"error:foo:bar","body":{"message":"Foo Bar","stack":"foo bar stack"}}',
60+
body: '{"user":{"name":"foo","avatar":"https://example.com"},"timestamp":"1970-01-01T00:00:00.000Z","level":"error","namespace":"error:foo:bar","body":{"message":"Foo Bar","stack":"foo bar stack"}}',
5961
}));
6062
});
6163
});

0 commit comments

Comments
 (0)