Skip to content

Commit e61092f

Browse files
fix bug which fails auth when server doesnt provide scope (#117)
1 parent 069a697 commit e61092f

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

ci/compose.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ function compose_down_all {
1919
}
2020

2121
function all_weaviate_ports {
22-
echo "8080 8081 8082 8083 8085"
22+
echo "8080 8081 8082 8083 8085 8086"
2323
}

ci/docker-compose-wcs-noscope.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
version: '3.4'
3+
services:
4+
weaviate-auth-wcs-noscopes:
5+
command:
6+
- --host
7+
- 0.0.0.0
8+
- --port
9+
- '8086'
10+
- --scheme
11+
- http
12+
- --write-timeout=600s
13+
image: semitechnologies/weaviate:1.17.0
14+
ports:
15+
- 8086:8086
16+
restart: on-failure:0
17+
environment:
18+
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
19+
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'false'
20+
AUTHENTICATION_OIDC_ENABLED: 'true'
21+
AUTHENTICATION_OIDC_CLIENT_ID: 'wcs'
22+
AUTHENTICATION_OIDC_ISSUER: 'https://auth.wcs.api.semi.technology/auth/realms/SeMI'
23+
AUTHENTICATION_OIDC_USERNAME_CLAIM: 'email'
24+
AUTHENTICATION_OIDC_GROUPS_CLAIM: 'groups'
25+
AUTHORIZATION_ADMINLIST_ENABLED: 'true'
26+
AUTHORIZATION_ADMINLIST_USERS: '[email protected]'
27+
...

connection/auth.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ export class Authenticator {
4949
getOpenidConfig = async (localConfig) => {
5050
return this.http.externalGet(localConfig.href)
5151
.then(openidProviderConfig => {
52+
let scopes = localConfig.scopes || [];
5253
return {
5354
clientId: localConfig.clientId,
5455
provider: openidProviderConfig,
55-
scopes: localConfig.scopes
56+
scopes: scopes
5657
};
5758
});
5859
};

connection/journey.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,25 @@ describe("connection", () => {
103103
.catch((e) => fail("it should not have errord: " + e));
104104
})
105105

106+
it("makes a scopeless WCS logged-in request with username/password", async () => {
107+
const client = weaviate.client({
108+
scheme: "http",
109+
host: "localhost:8086",
110+
authClientSecret: new AuthUserPasswordCredentials({
111+
username: "[email protected]",
112+
password: process.env.WCS_DUMMY_CI_PW
113+
})
114+
})
115+
116+
return client.misc
117+
.metaGetter()
118+
.do()
119+
.then((res) => {
120+
expect(res.version).toBeDefined();;
121+
})
122+
.catch((e) => fail("it should not have errord: " + e));
123+
})
124+
106125
it("makes a logged-in request with access token", async () => {
107126
if (process.env.WCS_DUMMY_CI_PW == undefined || process.env.WCS_DUMMY_CI_PW == "") {
108127
console.warn("Skipping because `WCS_DUMMY_CI_PW` is not set");

0 commit comments

Comments
 (0)