Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit aaa71a7

Browse files
author
Panagis Tselentis
committed
Merge branch 'next'
2 parents 853518f + 11f3c8a commit aaa71a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1071
-2254
lines changed

.env_example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PORT=1337
2+
NODE_ENV=production
3+
KONGA_HOOK_TIMEOUT=120000
4+
DB_ADAPTER=postgres
5+
DB_URI=postgresql://localhost:5432/konga
6+
KONGA_LOG_LEVEL=warn
7+
TOKEN_SECRET=some_secret_token

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,6 @@ nbproject
121121
/config/mssqlconfig.js
122122
/www/
123123
/kongadata/
124+
/certs/
125+
/.env
126+
.env

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.12.1](https://github.com/pantsel/konga/releases/tag/0.12.1) - 28-07-2018
6+
* **[Deprecation]** Deprecated consumer imports. This feature was not adopted and provided unnecessary
7+
complexity to maintenance as well as increased the overall project's size.
8+
* **[Fix]** Fixed the trailing slash issue. Konga is now able to communicate with
9+
Kong even if a trailing slash exists in the connection url.
10+
* Cleaned up unused dependencies.
11+
* When installing Konga from source, the `confing/local.js` file is deprecated
12+
in favor of a `.env` file. Check the README.md for details.
13+
514
## [0.12.0](https://github.com/pantsel/konga/releases/tag/0.12.0) - 07-07-2018
615
* **[Fix]** Fix snapshots implementation. Use auto generated entity ids for proper relationships mapping.
716
* **[Compatibility]** Implement new Kong plugins properly.

README.md

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ _Konga is not an official app. No affiliation with [Kong](https://www.konghq.com
2020
- [**Used libraries**](#used-libraries)
2121
- [**Installation**](#installation)
2222
- [**Configuration**](#configuration)
23+
- [**Environment variables**](#environment-variables)
2324
- [**Running Konga**](#running-konga)
2425
- [**Upgrading**](#upgrading)
2526
- [**FAQ**](#faq)
@@ -51,37 +52,58 @@ It also works with Kong 0.13.* yet without the ability to manage services and ro
5152

5253
## Prerequisites
5354
- A running [Kong installation](https://getkong.org/)
54-
- Nodejs
55+
- Nodejs >= 8 (8.11.3 LTS is recommended)
5556
- Npm
5657

5758
## Used libraries
5859
* Sails.js, http://sailsjs.org/
5960
* AngularJS, https://angularjs.org/
60-
* Bootstrap, http://getbootstrap.com/
6161

6262
## Installation
6363

6464
Install `npm` and `node.js`. Instructions can be found [here](http://sailsjs.org/#/getStarted?q=what-os-do-i-need).
6565

66-
Install `bower`, `gulp` and `sails` packages.
66+
Install `bower`, ad `gulp` packages.
6767
```
6868
$ git clone https://github.com/pantsel/konga.git
6969
$ cd konga
70-
$ npm install
70+
$ npm i
7171
```
7272

7373
## Configuration
7474
You can configure your application to use your environment specified
7575
settings.
7676

77-
There is an example configuration file on following path.
77+
There is an example configuration file on the root folder.
7878

7979
```
80-
config/local_example.js
80+
.env_example
8181
```
8282

83-
Just copy this to `config/local.js` and make necessary changes to it. Note that this
84-
`local.js` file is in .gitignore so it won't go to VCS at any point.
83+
Just copy this to `.env` and make necessary changes to it. Note that this
84+
`.env` file is in .gitignore so it won't go to VCS at any point.
85+
86+
## Environment variables
87+
These are the general environment variables Konga uses.
88+
89+
| VAR | DESCRIPTION | VALUES | DEFAULT |
90+
|--------------------|----------------------------------------------------------------------------------------------------------------------------|----------------------------------------|----------------------------------------------|
91+
| PORT | The port that will be used by Konga's server | - | 1337 |
92+
| NODE_ENV | The environment | `production`,`development` | `development` |
93+
| SSL_KEY_PATH | If you want to use SSL, this will be the absolute path to the .key file. Both `SSL_KEY_PATH` & `SSL_CRT_PATH` must be set. | - | null |
94+
| SSL_CRT_PATH | If you want to use SSL, this will be the absolute path to the .crt file. Both `SSL_KEY_PATH` & `SSL_CRT_PATH` must be set. | - | null |
95+
| KONGA_HOOK_TIMEOUT | The time in ms that Konga will wait for startup tasks to finish before exiting the process. | - | 60000 |
96+
| DB_ADAPTER | The database that Konga will use. If not set, the localDisk db will be used. | `mongo`,`mysql`,`postgres`,`sqlserver` | - |
97+
| DB_URI | The full db connection string. Depends on `DB_ADAPTER`. If this is set, no other DB related var is needed. | - | - |
98+
| DB_HOST | If `DB_URI` is not specified, this is the database host. Depends on `DB_ADAPTER`. | - | localhost |
99+
| DB_PORT | If `DB_URI` is not specified, this is the database port. Depends on `DB_ADAPTER`. | - | DB default. |
100+
| DB_USER | If `DB_URI` is not specified, this is the database user. Depends on `DB_ADAPTER`. | - | - |
101+
| DB_PASSWORD | If `DB_URI` is not specified, this is the database user's password. Depends on `DB_ADAPTER`. | - | - |
102+
| DB_DATABASE | If `DB_URI` is not specified, this is the name of Konga's db. Depends on `DB_ADAPTER`. | - | `konga_database` |
103+
| DB_PG_SCHEMA | If using postgres as a database, this is the schema that will be used. | - | `public` |
104+
| KONGA_LOG_LEVEL | The logging level | `silly`,`debug`,`info`,`warn`,`error` | `debug` on dev environment & `warn` on prod. |
105+
| TOKEN_SECRET | The secret that will be used to sign JWT tokens issued by Konga | - | - |
106+
85107

86108
### Databases Integration
87109

@@ -94,45 +116,42 @@ The application also supports some of the most popular databases out of the box:
94116
1. MySQL
95117
2. MongoDB
96118
3. PostgresSQL
97-
4. SQL Server
98119

99-
In order to use them, in your `/config/local.js` replace
100-
```
101-
models: {
102-
connection: process.env.DB_ADAPTER || 'localDiskDb',
103-
}
104-
```
105-
with
120+
In order to use them, set the appropriate env vars in your `.env` file.
121+
122+
123+
## Running Konga
124+
125+
### Development
106126
```
107-
models: {
108-
connection: process.env.DB_ADAPTER || 'the-name-of-adapter-you-wish-to-use', // 'mysql', 'mongo', 'sqlserver' or 'postgres'
109-
}
127+
$ npm start
110128
```
129+
Konga GUI will be available at `http://localhost:1337`
111130

112-
See [Sails adapters](http://sailsjs.com/documentation/concepts/extending-sails/adapters/available-adapters) for further configuration
131+
### Production
113132

114133
*****************************************************************************************
115-
##### Note :
116-
In case of `MySQL`, `PostgresSQL` or `SQL Server` adapters,
117-
you will need to prepare the database as explained on the next topic.
134+
In case of `MySQL` or `PostgresSQL` adapters, Konga will not perform db migrations when running in production mode.
118135

119-
*****************************************************************************************
136+
You can manually perform the migrations by calling ```$ node ./bin/konga.js prepare```
137+
, passing the args needed for the database connectivity.
120138

121-
## Running Konga
139+
For example:
122140

123-
### Development
124141
```
125-
$ npm start
142+
$ node ./bin/konga.js prepare --adapter postgres --uri postgresql://localhost:5432/konga
126143
```
127-
Konga GUI will be available at `http://localhost:1337`
144+
The process will exit after all migrations are completed.
128145

129-
### Production
146+
*****************************************************************************************
130147

148+
Finally:
131149
```
132150
$ npm run production
133151
```
134152
Konga GUI will be available at `http://localhost:1337`
135153

154+
136155
### Production Docker Image
137156

138157
The following instructions assume that you have a running Kong instance following the
@@ -143,6 +162,7 @@ $ docker run -p 1337:1337 \
143162
--network {{kong-network}} \ // optional
144163
--name konga \
145164
-e "NODE_ENV=production" \ // or "development" | defaults to 'development'
165+
-e "TOKEN_SECRET={{somerandomstring}}" \
146166
pantsel/konga
147167
```
148168

@@ -151,20 +171,7 @@ $ docker run -p 1337:1337 \
151171
1. ##### Prepare the database
152172
> **Note**: You can skip this step if using the `mongo` adapter.
153173
154-
Konga will not perform db migrations when running in production mode.
155-
156-
You can manually perform the migrations by calling ```$ node ./bin/konga.js prepare```
157-
, passing the args needed for the database connectivity.
158-
159-
The available adapters are ```'postgres', or 'mysql'```
160-
161-
```
162-
$ node ./bin/konga.js prepare --adapter {adapter_name} --uri {full_connection_string}
163-
```
164-
The process will exit after all migrations are completed.
165-
166-
If you're deploying Konga via the docker image, you can prepare the database using
167-
an ephemeral container running the prepare command.
174+
You can prepare the database using an ephemeral container that runs the prepare command.
168175

169176
**Args**
170177

@@ -173,17 +180,17 @@ argument | description | default
173180
-c | command | -
174181
-a | adapter (can be `postgres` or `mysql`) | -
175182
-u | full database connection url | -
176-
-p | port | `1339`
177183

178184
```
179-
$ docker run --rm pantsel/konga:next -c prepare -a {{adapter}} -u {{connection-uri}} -p {{port}}
185+
$ docker run --rm pantsel/konga:next -c prepare -a {{adapter}} -u {{connection-uri}}
180186
```
181187

182188

183189
2. ##### Start Konga
184190
```
185191
$ docker run -p 1337:1337
186192
--network {{kong-network}} \ // optional
193+
-e "TOKEN_SECRET={{somerandomstring}}" \
187194
-e "DB_ADAPTER=the-name-of-the-adapter" \ // 'mongo','postgres','sqlserver' or 'mysql'
188195
-e "DB_HOST=your-db-hostname" \
189196
-e "DB_PORT=your-db-port" \ // Defaults to the default db port
@@ -199,6 +206,7 @@ $ docker run -p 1337:1337
199206
// Alternatively you can use the full connection string to connect to a database
200207
$ docker run -p 1337:1337
201208
--network {{kong-network}} \ // optional
209+
-e "TOKEN_SECRET={{somerandomstring}}" \
202210
-e "DB_ADAPTER=the-name-of-the-adapter" \ // 'mongo','postgres','sqlserver' or 'mysql'
203211
-e "DB_URI=full-conection-uri" \
204212
-e "NODE_ENV=production" \ // or 'development' | defaults to 'development'
@@ -217,7 +225,10 @@ login: admin | password: adminadminadmin
217225
*Demo user*
218226
login: demo | password: demodemodemo
219227

220-
This user data is populated to the database if there is not already any user data in it. [It is possible to alter the default user seed data.](DEFAULTUSERSEEDDATA.md)
228+
This user data is populated to the database if there is not already any user data in it. [It is possible to alter the default user seed data.](./docs/DEFAULTUSERSEEDDATA.md)
229+
230+
You may also configure Konga to authenticate via [LDAP](./docs/LDAP.md).
231+
221232

222233
## Upgrading
223234
In some cases a newer version of Konga may introduce new db tables, collections or changes in schemas.

api/controllers/KongProxyController.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var unirest = require("unirest");
66
var KongService = require("../services/KongService");
77
var ProxyHooks = require("../services/KongProxyHooks");
88
var _ = require("lodash");
9+
var Utils = require('../services/Utils');
910

1011

1112
function getEntityFromRequest(req) {
@@ -44,6 +45,7 @@ var self = module.exports = {
4445
});
4546
}
4647

48+
sails.log("Kong admin url =>", req.connection.kong_admin_url);
4749

4850
var request = unirest[req.method.toLowerCase()](req.connection.kong_admin_url + req.url)
4951

api/controllers/RemoteStorageController.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

api/helpers/utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ module.exports = {
7272
}
7373

7474
return version;
75-
}
75+
},
7676

77+
withoutTrailingSlash(str) {
78+
if(!str) return str;
79+
return str.replace(/\/$/, "")
80+
},
7781
}

api/policies/authenticated.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = function authenticated(request, response, next) {
2525
*/
2626
var verify = function verify(error, token) {
2727
if (!(_.isEmpty(error) && token !== -1)) {
28-
return response.json(401, {message: 'Given authorization token is not valid'});
28+
return response.json(401, {message: 'Given authorization token is not valid', logout: true});
2929
} else {
3030
// Store user id to request object
3131
request.token = token;
@@ -42,6 +42,6 @@ module.exports = function authenticated(request, response, next) {
4242
try {
4343
sails.services.token.getToken(request, verify, true);
4444
} catch (error) {
45-
return response.json(401, {message: error.message});
45+
return response.json(401, {message: error.message, logout: true});
4646
}
4747
};

0 commit comments

Comments
 (0)