Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/city-of-helsinki/kaavoitus-api
https://github.com/city-of-helsinki/kaavoitus-api
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/city-of-helsinki/kaavoitus-api
- Owner: City-of-Helsinki
- Created: 2021-01-18T08:24:47.000Z (almost 4 years ago)
- Default Branch: development
- Last Pushed: 2024-10-29T08:09:17.000Z (about 2 months ago)
- Last Synced: 2024-10-29T09:26:02.321Z (about 2 months ago)
- Language: Python
- Size: 511 KB
- Stars: 1
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kaavoitus-API
Django/REST application for providing connectivity
between three planning applications:* Kaavapino
- https://github.com/City-of-Helsinki/kaavapino/
- https://github.com/City-of-Helsinki/kaavapino-ui/* Facta
* GeoServer- https://kartta.hel.fi/avoindata/
## Logging
By default, logging will be done to console on level 'WARNING'.
Environment setting file `config_dev.env` can be used to change this.
Example, set log level to debug:
```
LOG_LEVEL=DEBUG
```## Facta DB mocking
For development running a mocked Oracle SQL can be done.
Environment setting file `config_dev.env` can be used to enable this behaviour.
Example, don't try to connect to Oracle SQL, use pre-loaded data from directory `mock-data/`:
```
FACTA_DB_MOCK_DATA_DIR='mock-data/'
```## Authentication
Only API-key is supported.
Access to any of the resources is bound to an API-key.
It is possible to allow or deny access to any of the three sources.## Add external credential
Syntax:
`drf_ext_credentials --add [system] [owner] [username] [credential] [host_spec (optional)]`
`drf_ext_credentials --reset [system] [owner] [username] [credential] [host_spec (optional)]`
```bash
$ ./manage.py drf_ext_credentials --add Kaavapino Kaavapino Kaavapino test
```Alternative for development, SQLite will be used:
```bash
$ sqlite3 db.sqlite3
sqlite>
```**Example:** Add Oracle SQL credentials issued to Kaavapino-project for Facta access.
On `sqlite>`-prompt:
```sql
INSERT INTO
ext_auth_cred (
"system", "cred_owner", "username", "credential", "host_spec"
)
VALUES (
"Facta",
"Kaavapino",
"KP-user",
"Secret! Don't tell anyone",
"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = FACTA)))"
);
```Take a note of the ID issued to the credential in database.
## List existing external credentials:
Note: The actual credentials are not displayed.
```bash
$ ./manage.py drf_ext_credentials
Id System Owner
--- -------------------- --------------------
1: GeoServer Kaavapino
2: Facta Kaavapino
3: Kaavapino Kaavapino
```## Add API-key
Syntax:
```bash
$ ./manage.py drf_create_token
usage: manage.py drf_create_token [-h] [-r] [--access-facta EXT-CRED-ID] [--access-geoserver EXT-CRED-ID] [--access-kaavapino EXT-CRED-ID] [--version] [-v {0,1,2,3}]
[--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color] [--skip-checks]
username```
Note: Internally Django works with users. An API-key needs to be bound to an user.
Note 2 options for external systems:
* `--access-facta EXT-CRED-ID` If access to Facta DB is allowed via this API, specify which credential to use for access
* `--access-geoserver EXT-CRED-ID` If access to GeoServer is allowed via this API, specify which credential to use for access
* `--access-kaavapino EXT-CRED-ID` If access to Kaavapino is allowed via this API, specify which credential to use for access### Example:
Add API-key to user _kaavapino_ with access to all systems.
Use pre-stored external credential with ID 1 for Facta, ID 2 for GeoServer and ID 3 for Kaavapino:```bash
$ ./manage.py drf_create_token \
--access-facta 1 \
--access-geoserver 2 \
--access-kaavapino 3 \
kaavapino
```