Skip to content

Commit eac37f2

Browse files
authored
Issue/25 default auth not working (#28)
* Fixed basic auth for SimpleTenantApp to include the tenant ID in the username. * Minor cleanup.
1 parent d76e042 commit eac37f2

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
## Work in progress
55

6+
* Fixed https://github.com/SoftwareAG/cumulocity-python-api/issues/25
7+
The SimpleTenantApp did not include the tenant ID into the username which is not supported
8+
by all Cumulocity instances.
9+
610
* Adding class _QueryUtil, bundling query encoding related functionality.
711

812
* Added tests for special character parsing.

c8y_api/app/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def __init__(self, application_key: str = None, cache_size: int = 100, cache_ttl
134134
username = self._get_env('C8Y_USER')
135135
password = self._get_env('C8Y_PASSWORD')
136136
super().__init__(log=self._log, cache_size=cache_size, cache_ttl=cache_ttl,
137-
base_url=baseurl, tenant_id=tenant_id, auth=HTTPBasicAuth(username, password),
137+
base_url=baseurl, tenant_id=tenant_id, auth=HTTPBasicAuth(f'{tenant_id}/{username}', password),
138138
application_key=application_key)
139139

140140
def _build_user_instance(self, auth) -> CumulocityApi:

samples/build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ sed -e "s/{SAMPLE}/$NAME/g" ./samples/Dockerfile > "$BUILD_DIR/Dockerfile"
3939

4040
docker build -t "$NAME" "$BUILD_DIR"
4141
docker save -o "$DIST_DIR/image.tar" "$NAME"
42-
ARCHIVE =
4342
zip -j "$DIST_DIR/$IMG_NAME.zip" "$BUILD_DIR/cumulocity.json" "$DIST_DIR/image.tar"
4443

4544
echo ""

samples/cumulocity.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
},
77
"isolation": "MULTI_TENANT",
88
"requiredRoles": [
9-
"ROLE_INVENTORY_READ"
9+
"ROLE_INVENTORY_ADMIN",
10+
"ROLE_USER_MANAGEMENT_READ",
11+
"ROLE_MEASUREMENT_ADMIN"
1012
],
1113
"livenessProbe": {
1214
"httpGet": {

samples/user_sessions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# as specifically provided for in your License Agreement with Software AG.
66

77
"""
8-
This sample code demonstates how to obtain Cumulocity user sessions (sessions
8+
This sample code demonstrates how to obtain Cumulocity user sessions (sessions
99
that are run within the context of a named user).
1010
1111
When writing a micro service for Cumulocity you always have two options to

0 commit comments

Comments
 (0)