Implemented OpenId configuration.
Change-Id: I4e41a6072797742266d86c1709ad8941ae2c17f1
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java
index 98502ea..15d627f 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java
@@ -1,8 +1,8 @@
package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -103,35 +103,6 @@
}
- private void checkAndAll (String json) throws KustvaktException {
- JsonNode node = JsonUtils.readTree(json);
- assertNotNull(node);
- assertEquals("availability(ALL)",
- node.at("/collection/rewrites/0/scope").asText());
- assertEquals("operation:insertion",
- node.at("/collection/rewrites/0/operation").asText());
-
- assertEquals("operation:and",
- node.at("/collection/operation").asText());
-
- node = node.at("/collection/operands/0");
- assertEquals("operation:or", node.at("/operation").asText());
-
- assertEquals("match:eq", node.at("/operands/0/match").asText());
- assertEquals("match:eq", node.at("/operands/0/match").asText());
- assertEquals("type:regex", node.at("/operands/0/type").asText());
- assertEquals("availability", node.at("/operands/0/key").asText());
- assertEquals("CC-BY.*", node.at("/operands/0/value").asText());
-
- node = node.at("/operands/1");
- assertEquals("operation:or", node.at("/operation").asText());
- assertEquals("match:eq", node.at("/operands/0/match").asText());
- assertEquals("ACA.*", node.at("/operands/0/value").asText());
- assertEquals("match:eq", node.at("/operands/1/match").asText());
- assertEquals("QAO.*", node.at("/operands/1/value").asText());
-
- }
-
private void checkAndAllWithACA (String json) throws KustvaktException {
JsonNode node = JsonUtils.readTree(json);
assertNotNull(node);
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java
index 97efe8d..497218c 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java
@@ -171,7 +171,7 @@
MultivaluedMap<String, String> authForm = new MultivaluedMapImpl();
authForm.add("response_type", "code");
authForm.add("client_id", "fCBbQkAyYzI4NzUxMg");
- authForm.add("scope", "read_username");
+ authForm.add("scope", "username");
ClientResponse response =
requestAuthorizationConfidentialClient(authForm);
@@ -181,7 +181,7 @@
String code = params.get("code").get(0);
String scopes = params.get("scope").get(0);
- assertEquals(scopes, "read_username");
+ assertEquals(scopes, "username");
MultivaluedMap<String, String> tokenForm = new MultivaluedMapImpl();
tokenForm.add("grant_type", "authorization_code");
@@ -241,7 +241,7 @@
MultivaluedMap<String, String> authForm = new MultivaluedMapImpl();
authForm.add("response_type", "code");
authForm.add("client_id", "fCBbQkAyYzI4NzUxMg");
- authForm.add("scope", "read_username");
+ authForm.add("scope", "username");
authForm.add("redirect_uri", uri);
ClientResponse response =
@@ -437,7 +437,7 @@
form.add("grant_type", "client_credentials");
form.add("client_id", "fCBbQkAyYzI4NzUxMg");
form.add("client_secret", "secret");
- form.add("scope", "read_username read_client_info");
+ form.add("scope", "preferred_username client_info");
ClientResponse response = requestToken(form);
String entity = response.getEntity(String.class);
@@ -450,7 +450,7 @@
assertEquals(TokenType.BEARER.toString(),
node.at("/token_type").asText());
assertNotNull(node.at("/expires_in").asText());
- assertEquals("read_client_info", node.at("/scope").asText());
+ assertEquals("client_info", node.at("/scope").asText());
}
@Test
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2OpenIdControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2OpenIdControllerTest.java
index 5459c6d..6594fdd 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2OpenIdControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2OpenIdControllerTest.java
@@ -316,7 +316,7 @@
@Test
public void testPublicKeyAPI () throws KustvaktException {
ClientResponse response = resource().path("oauth2").path("openid")
- .path("key").path("public").get(ClientResponse.class);
+ .path("jwks").get(ClientResponse.class);
String entity = response.getEntity(String.class);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(1,node.at("/keys").size());
@@ -326,4 +326,18 @@
assertNotNull(node.at("/e").asText());
assertNotNull(node.at("/n").asText());
}
+
+ @Test
+ public void testOpenIDConfiguration () throws KustvaktException {
+ ClientResponse response = resource().path("oauth2").path("openid")
+ .path("config").get(ClientResponse.class);
+ String entity = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(entity);
+ assertNotNull(node.at("/issuer"));
+ assertNotNull(node.at("/authorization_endpoint"));
+ assertNotNull(node.at("/token_endpoint"));
+ assertNotNull(node.at("/response_types_supported"));
+ assertNotNull(node.at("/subject_types_supported"));
+ assertNotNull(node.at("/id_token_signing_alg_values_supported"));
+ }
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java
index e96e523..fa40e73 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java
@@ -14,7 +14,6 @@
import de.ids_mannheim.korap.authentication.http.HttpAuthorizationHandler;
import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.constant.TokenType;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.web.FastJerseyTest;
diff --git a/full/src/test/resources/kustvakt-test.conf b/full/src/test/resources/kustvakt-test.conf
index 48ce51c..9061918 100644
--- a/full/src/test/resources/kustvakt-test.conf
+++ b/full/src/test/resources/kustvakt-test.conf
@@ -43,18 +43,36 @@
## options referring to the security module!
-## OAuth
+## OAuth
### (see de.ids_mannheim.korap.constant.AuthenticationMethod for possible
### oauth.password.authentication values)
-oauth.password.authentication = TEST
-oauth.native.client.host=korap.ids-mannheim.de
+oauth2.password.authentication = TEST
+oauth2.native.client.host = korap.ids-mannheim.de
oauth2.max.attempts = 2
# -- scopes separated by space
-oauth2.default.scopes = openid read_username read_email
-oauth2.client.credentials.scopes = read_client_info
+oauth2.default.scopes = openid username email
+oauth2.client.credentials.scopes = client_info
+
+## OpenId
+### multiple values are separated by space
+openid.grant.types = authorization_code
+openid.response.types = code
+openid.response.modes = query
+openid.client.auth.methods = client_secret_basic client_secret_post
+openid.token.signing.algorithms = RS256
+openid.subject.types = public
+openid.display.types = page
+openid.supported.scopes = openid email
+openid.support.claim.param = false
+openid.claim.types = normal
+openid.supported.claims = iss sub aud exp iat
+openid.ui.locales = en
+#openid.privacy.policy =
+#openid.term.of.service =
+openid.service.doc = https://github.com/KorAP/Kustvakt/wiki
## JWT
-security.jwt.issuer=korap.ids-mannheim.de
+security.jwt.issuer=https://korap.ids-mannheim.de
## JWK
rsa.private = kustvakt_rsa.key