diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/SessionIdUserTokenGenerator.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/SessionIdUserTokenGenerator.java
index 85a04890c..dbc1d0014 100644
--- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/SessionIdUserTokenGenerator.java
+++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/SessionIdUserTokenGenerator.java
@@ -24,7 +24,7 @@ public class SessionIdUserTokenGenerator implements UserTokenGenerator ,Serializ
if(null==request)throw new UnsupportedOperationException();
- int timeout =request.getSession().getMaxInactiveInterval();
+ int timeout =request.getSession().getMaxInactiveInterval()*1000;
String sessionId = request.getSession().getId();
diff --git a/hsweb-authorization/hsweb-authorization-jwt/src/main/java/org/hswebframework/web/authorization/jwt/JwtAutoConfiguration.java b/hsweb-authorization/hsweb-authorization-jwt/src/main/java/org/hswebframework/web/authorization/jwt/JwtAutoConfiguration.java
new file mode 100644
index 000000000..e6799a715
--- /dev/null
+++ b/hsweb-authorization/hsweb-authorization-jwt/src/main/java/org/hswebframework/web/authorization/jwt/JwtAutoConfiguration.java
@@ -0,0 +1,28 @@
+package org.hswebframework.web.authorization.jwt;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author zhouhao
+ */
+@Configuration
+public class JwtAutoConfiguration {
+
+ @Bean
+ @ConfigurationProperties(prefix = "hsweb.authorize.jwt")
+ public JwtConfig jwtConfig(){
+ return new JwtConfig();
+ }
+
+ @Bean
+ public JwtTokenGenerator jwtTokenGenerator(JwtConfig config){
+ return new JwtTokenGenerator(config);
+ }
+
+ @Bean
+ public JwtTokenParser jwtTokenParser(JwtConfig config){
+ return new JwtTokenParser(config);
+ }
+}
diff --git a/hsweb-authorization/hsweb-authorization-jwt/src/main/java/org/hswebframework/web/authorization/jwt/JwtTokenGenarator.java b/hsweb-authorization/hsweb-authorization-jwt/src/main/java/org/hswebframework/web/authorization/jwt/JwtTokenGenerator.java
similarity index 91%
rename from hsweb-authorization/hsweb-authorization-jwt/src/main/java/org/hswebframework/web/authorization/jwt/JwtTokenGenarator.java
rename to hsweb-authorization/hsweb-authorization-jwt/src/main/java/org/hswebframework/web/authorization/jwt/JwtTokenGenerator.java
index deac1bd71..3c8c2c8f0 100644
--- a/hsweb-authorization/hsweb-authorization-jwt/src/main/java/org/hswebframework/web/authorization/jwt/JwtTokenGenarator.java
+++ b/hsweb-authorization/hsweb-authorization-jwt/src/main/java/org/hswebframework/web/authorization/jwt/JwtTokenGenerator.java
@@ -11,20 +11,18 @@ import org.hswebframework.web.authorization.basic.web.UserTokenGenerator;
import org.hswebframework.web.id.IDGenerator;
import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
- * Created by zhouhao on 2017/8/30.
+ *
*/
-public class JwtTokenGenarator implements UserTokenGenerator {
+public class JwtTokenGenerator implements UserTokenGenerator {
private JwtConfig jwtConfig;
- public JwtTokenGenarator(JwtConfig jwtConfig) {
+ public JwtTokenGenerator(JwtConfig jwtConfig) {
this.jwtConfig = jwtConfig;
}
@@ -43,6 +41,7 @@ public class JwtTokenGenarator implements UserTokenGenerator {
String jwtToken = createJWT(jwtConfig.getId(),token,jwtConfig.getTtl());
String refreshToken = createJWT(jwtConfig.getId(),token,jwtConfig.getRefreshTtl());
+
int timeout = jwtConfig.getTtl();
return new TokenResult() {
diff --git a/hsweb-authorization/hsweb-authorization-jwt/src/main/resources/META-INF/spring.factories b/hsweb-authorization/hsweb-authorization-jwt/src/main/resources/META-INF/spring.factories
new file mode 100644
index 000000000..efb616ec9
--- /dev/null
+++ b/hsweb-authorization/hsweb-authorization-jwt/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,3 @@
+# Auto Configure
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.hswebframework.web.authorization.jwt.JwtAutoConfiguration
\ No newline at end of file
diff --git a/hsweb-examples/hsweb-examples-simple/pom.xml b/hsweb-examples/hsweb-examples-simple/pom.xml
index b2f6504c6..3cc88c203 100644
--- a/hsweb-examples/hsweb-examples-simple/pom.xml
+++ b/hsweb-examples/hsweb-examples-simple/pom.xml
@@ -120,6 +120,12 @@
hsweb-authorization-basic
${project.version}
+
+
+ org.hswebframework.web
+ hsweb-authorization-jwt
+ ${project.version}
+
diff --git a/hsweb-examples/hsweb-examples-simple/src/main/java/org/hswebframework/web/example/simple/TestController.java b/hsweb-examples/hsweb-examples-simple/src/main/java/org/hswebframework/web/example/simple/TestController.java
index 15e322d69..8033b1034 100644
--- a/hsweb-examples/hsweb-examples-simple/src/main/java/org/hswebframework/web/example/simple/TestController.java
+++ b/hsweb-examples/hsweb-examples-simple/src/main/java/org/hswebframework/web/example/simple/TestController.java
@@ -1,6 +1,7 @@
package org.hswebframework.web.example.simple;
import io.swagger.annotations.ApiOperation;
+import org.apache.commons.codec.digest.DigestUtils;
import org.hswebframework.web.authorization.Authentication;
import org.hswebframework.web.authorization.Permission;
import org.hswebframework.web.authorization.annotation.Authorize;
@@ -20,6 +21,7 @@ import org.hswebframework.web.service.QueryByEntityService;
import org.hswebframework.web.service.QueryService;
import org.springframework.web.bind.annotation.*;
+import java.util.Base64;
import java.util.List;
@@ -133,4 +135,9 @@ public class TestController implements QueryController