jwt.go 543 B

123456789101112131415161718192021222324252627
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package parser
  4. import (
  5. "cp-system-management-gateway/config"
  6. "github.com/jaryhe/gopkgs/jwtwrapper"
  7. )
  8. var jwtConfig config.JwtConfig
  9. func JwtHandler(conf *config.Configure) {
  10. // jwtConfig 不为空表示已经初始化
  11. if jwtConfig.Secret != "" {
  12. // 无变化,直接返回
  13. if jwtConfig.Secret == conf.Jwt.Secret {
  14. return
  15. }
  16. }
  17. // 重置设置jwt secret
  18. jwtwrapper.SetSecret(conf.Jwt.Secret)
  19. jwtConfig = conf.Jwt
  20. }