1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: add support for basic auth with simple-auth (#659)

This commit is contained in:
Ivar Conradi Østhus 2020-12-03 21:29:01 +01:00 committed by GitHub
parent e3bfe2c6d0
commit 3bf01b803a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 2 deletions

View File

@ -3,6 +3,8 @@ id: events
title: /api/admin/events
---
> In order to access the admin api endpoints you need to identify yourself. If you are using the `unsecure` authententication method, you may use [basic authenticaion](https://en.wikipedia.org/wiki/Basic_access_authentication) to ientify yourself.
# Events API
`GET: http://unleash.host.com/api/admin/events`

View File

@ -3,6 +3,8 @@ id: features
title: /api/admin/features
---
> In order to access the admin api endpoints you need to identify yourself. If you are using the `unsecure` authententication method, you may use [basic authenticaion](https://en.wikipedia.org/wiki/Basic_access_authentication) to ientify yourself.
### Fetching Feature Toggles
`GET: http://unleash.host.com/api/admin/features`

View File

@ -3,6 +3,8 @@ id: feature-types
title: /api/admin/feature-types
---
> In order to access the admin api endpoints you need to identify yourself. If you are using the `unsecure` authententication method, you may use [basic authenticaion](https://en.wikipedia.org/wiki/Basic_access_authentication) to ientify yourself.
# Feature Types API
`GET: http://unleash.host.com/api/admin/feature-types`

View File

@ -3,6 +3,8 @@ id: metrics
title: /api/admin/metrics
---
> In order to access the admin api endpoints you need to identify yourself. If you are using the `unsecure` authententication method, you may use [basic authenticaion](https://en.wikipedia.org/wiki/Basic_access_authentication) to ientify yourself.
# This document describes the metrics endpoint for admin ui
### Seen-toggles

View File

@ -3,6 +3,8 @@ id: state
title: /api/admin/state
---
> In order to access the admin api endpoints you need to identify yourself. If you are using the `unsecure` authententication method, you may use [basic authenticaion](https://en.wikipedia.org/wiki/Basic_access_authentication) to ientify yourself.
### Export Feature Toggles & Strategies
`GET: http://unleash.host.com/api/admin/state/export`

View File

@ -3,6 +3,8 @@ id: strategies
title: /api/admin/strategies
---
> In order to access the admin api endpoints you need to identify yourself. If you are using the `unsecure` authententication method, you may use [basic authenticaion](https://en.wikipedia.org/wiki/Basic_access_authentication) to ientify yourself.
### Fetch Strategies
`GET: http://unleash.host.com/api/admin/strategies`

View File

@ -1,5 +1,4 @@
'use strict';
const auth = require('basic-auth');
const User = require('../user');
const AuthenticationRequired = require('../authentication-required');
@ -15,6 +14,11 @@ function unsecureAuthentication(basePath = '', app) {
app.use(`${basePath}/api/admin/`, (req, res, next) => {
if (req.session.user && req.session.user.email) {
req.user = req.session.user;
} else if (req.header('authorization')) {
const user = auth(req);
if (user && user.name) {
req.user = new User({ username: user.name });
}
}
next();
});

View File

@ -63,6 +63,7 @@
},
"dependencies": {
"async": "^3.1.0",
"basic-auth": "^2.0.1",
"compression": "^1.7.3",
"cookie-parser": "^1.4.4",
"cookie-session": "^2.0.0-rc.1",

View File

@ -693,6 +693,13 @@ base@^0.11.1:
mixin-deep "^1.2.0"
pascalcase "^0.1.1"
basic-auth@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-2.0.1.tgz#b998279bf47ce38344b4f3cf916d4679bbf51e3a"
integrity sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==
dependencies:
safe-buffer "5.1.2"
bcrypt-pbkdf@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e"