mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
Document how to secure client api #231
This commit is contained in:
parent
fea601099a
commit
68a9feaa8a
@ -20,7 +20,6 @@ unleash.start({
|
|||||||
}).then(unleash => {
|
}).then(unleash => {
|
||||||
console.log(`Unleash started on http://localhost:${unleash.app.get('port')}`);
|
console.log(`Unleash started on http://localhost:${unleash.app.get('port')}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Examples on custom authentication hooks:
|
Examples on custom authentication hooks:
|
||||||
@ -42,7 +41,7 @@ UnleashConfig unleashConfig = UnleashConfig.builder()
|
|||||||
.build();
|
.build();
|
||||||
```
|
```
|
||||||
|
|
||||||
On the unleash server side you need to implement a preRouterHook hook which verifies that all calls to `/api/client` includes this pre shared key in the defined header. This could look something like this:
|
On the unleash server side you need to implement a preRouter hook which verifies that all calls to `/api/client` includes this pre shared key in the defined header. This could look something like this:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const unleash = require('unleash-server');
|
const unleash = require('unleash-server');
|
||||||
|
@ -9,7 +9,10 @@ const sharedSecret = '12312Random';
|
|||||||
unleash
|
unleash
|
||||||
.start({
|
.start({
|
||||||
databaseUrl: 'postgres://unleash_user:passord@localhost:5432/unleash',
|
databaseUrl: 'postgres://unleash_user:passord@localhost:5432/unleash',
|
||||||
|
<<<<<<< HEAD
|
||||||
enableLegacyRoutes: false,
|
enableLegacyRoutes: false,
|
||||||
|
=======
|
||||||
|
>>>>>>> 0681945... Document how to secure client api #231
|
||||||
preRouterHook: app => {
|
preRouterHook: app => {
|
||||||
app.use('/api/client', (req, res, next) => {
|
app.use('/api/client', (req, res, next) => {
|
||||||
if (req.headers.authorization === sharedSecret) {
|
if (req.headers.authorization === sharedSecret) {
|
||||||
|
Loading…
Reference in New Issue
Block a user