Added storing authorization code and access token in cache; fixed bugs.
Change-Id: Ibc555ed65ebec8e7b40a76521311680a63c11a09
diff --git a/full/src/main/resources/db/new-mysql/V1.4__oauth2_tables.sql b/full/src/main/resources/db/new-mysql/V1.4__oauth2_tables.sql
index 234df42..b8df487 100644
--- a/full/src/main/resources/db/new-mysql/V1.4__oauth2_tables.sql
+++ b/full/src/main/resources/db/new-mysql/V1.4__oauth2_tables.sql
@@ -54,14 +54,13 @@
CREATE TABLE IF NOT EXISTS oauth2_access_token (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
token VARCHAR(255) NOT NULL,
- authorization_id INTEGER DEFAULT NULL,
user_id VARCHAR(100) DEFAULT NULL,
+ client_id VARCHAR(100) DEFAULT NULL,
created_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_revoked BOOLEAN DEFAULT 0,
- total_attempts INTEGER DEFAULT 0,
user_auth_time TIMESTAMP NULL,
- FOREIGN KEY (authorization_id)
- REFERENCES oauth2_authorization(id)
+ FOREIGN KEY (client_id)
+ REFERENCES oauth2_client(id)
);
CREATE TABLE oauth2_access_token_scope (
diff --git a/full/src/main/resources/db/new-sqlite/V1.4__oauth2_tables.sql b/full/src/main/resources/db/new-sqlite/V1.4__oauth2_tables.sql
index f227752..2310c12 100644
--- a/full/src/main/resources/db/new-sqlite/V1.4__oauth2_tables.sql
+++ b/full/src/main/resources/db/new-sqlite/V1.4__oauth2_tables.sql
@@ -59,14 +59,13 @@
CREATE TABLE IF NOT EXISTS oauth2_access_token (
id INTEGER PRIMARY KEY AUTOINCREMENT,
token VARCHAR(255) NOT NULL,
- authorization_id INTEGER DEFAULT NULL,
user_id VARCHAR(100) DEFAULT NULL,
+ client_id VARCHAR(100) DEFAULT NULL,
created_date TIMESTAMP DEFAULT (datetime('now','localtime')),
is_revoked BOOLEAN DEFAULT 0,
- total_attempts INTEGER DEFAULT 0,
user_auth_time TIMESTAMP NOT NULL,
- FOREIGN KEY (authorization_id)
- REFERENCES oauth2_authorization(id)
+ FOREIGN KEY (client_id)
+ REFERENCES oauth2_client(id)
);
CREATE TABLE oauth2_access_token_scope (
diff --git a/full/src/main/resources/default-config.xml b/full/src/main/resources/default-config.xml
index 456ecff..90ea568 100644
--- a/full/src/main/resources/default-config.xml
+++ b/full/src/main/resources/default-config.xml
@@ -159,6 +159,7 @@
<!-- Data access objects -->
<bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao" />
<bean id="accessScopeDao" class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
+ <bean id="authorizationDao" class="de.ids_mannheim.korap.oauth2.dao.AuthorizationCacheDao" />
<!-- props are injected from default-config.xml -->
<bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
@@ -215,10 +216,6 @@
<constructor-arg ref="kustvakt_db" />
</bean>
- <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
<bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
<constructor-arg ref="kustvakt_db" />
</bean>
@@ -284,7 +281,6 @@
<util:list id="kustvakt_resources"
value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
<ref bean="document_provider" />
- <ref bean="resource_provider" />
</util:list>
<!-- specify type for constructor argument -->
diff --git a/full/src/main/resources/ehcache.xml b/full/src/main/resources/ehcache.xml
index 17cff24..be4e71e 100644
--- a/full/src/main/resources/ehcache.xml
+++ b/full/src/main/resources/ehcache.xml
@@ -3,38 +3,13 @@
<defaultCache eternal='true' overflowToDisk='false'/>
<!--maxBytesLocalHeap="200M"-->
<diskStore path="./cache_store"/>
-
- <cache name="documents"
- timeToIdleSeconds="172800"
- eternal='false'
- memoryStoreEvictionPolicy="LRU"
- maxEntriesLocalHeap="2000"
- overflowToDisk='false'/>
- <cache name='users'
- timeToIdleSeconds="172800"
- eternal='false'
- memoryStoreEvictionPolicy="LRU"
- maxEntriesLocalHeap="50"
- overflowToDisk='false'/>
+
<cache name='id_tokens'
eternal='true'
maxElementsOnDisk="10000000"
memoryStoreEvictionPolicy="LRU"
maxEntriesLocalHeap="50"
overflowToDisk='true'/>
- <cache name='id_tokens_inv'
- eternal='true'
- maxElementsOnDisk="10000000"
- memoryStoreEvictionPolicy="LRU"
- maxEntriesLocalHeap="50"
- overflowToDisk='true'/>
-
- <cache name='auth_sessions'
- timeToIdleSeconds="172800"
- eternal='false'
- memoryStoreEvictionPolicy="LRU"
- maxEntriesLocalHeap="100"
- overflowToDisk='false'/>
<cache name='auth_codes'
timeToIdleSeconds="600"
@@ -52,4 +27,21 @@
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
statistics="false"/>
+
+
+ <!-- EM -->
+ <cache name='authorization'
+ timeToLiveSeconds="1000"
+ eternal='false'
+ memoryStoreEvictionPolicy="LRU"
+ maxEntriesLocalHeap="100"
+ overflowToDisk='false'/>
+
+ <cache name='access_token'
+ timeToIdleSeconds="3600"
+ timeToLiveSeconds="15000"
+ eternal='false'
+ memoryStoreEvictionPolicy="LRU"
+ maxEntriesLocalHeap="500"
+ overflowToDisk='false'/>
</ehcache>
diff --git a/full/src/main/resources/kustvakt.conf b/full/src/main/resources/kustvakt.conf
index 654a1ab..0c21e43 100644
--- a/full/src/main/resources/kustvakt.conf
+++ b/full/src/main/resources/kustvakt.conf
@@ -48,7 +48,11 @@
### oauth.password.authentication values)
oauth.password.authentication = TEST
oauth2.native.client.host = korap.ids-mannheim.de
-oauth2.max.attempts = 3
+oauth2.max.attempts = 1
+# expiry in seconds (S), minutes (M), hours (H), days (D)
+oauth2.access.token.expiry = 1D
+oauth2.refresh.token.expiry = 90D
+oauth2.authorization.code.expiry = 10M
# -- scopes separated by space
oauth2.default.scopes = search match_info
oauth2.client.credentials.scopes = client_info
diff --git a/full/src/main/resources/kustvakt.info b/full/src/main/resources/kustvakt.info
index c1c6cea..4a0344a 100644
--- a/full/src/main/resources/kustvakt.info
+++ b/full/src/main/resources/kustvakt.info
@@ -4,5 +4,5 @@
# use this file to define the properties and logging file names
kustvakt.properties=./kustvakt.conf
kustvakt.logging=./log4j.properties
-kustvakt.caching=true
+kustvakt.cache=true
kustvakt.cache_store=./store
\ No newline at end of file