func Init()

in server/rbac/rbac.go [40:74]


func Init() {
	if !config.GetRBAC().Enabled {
		openlog.Info("rbac is disabled")
		return
	}

	jwt.Use(&jwt.Auth{
		MustAuth: func(req *http.Request) bool {
			if !config.GetRBAC().Enabled {
				return false
			}

			v := req.Header.Get(HeaderAuth)
			if config.GetRBAC().AllowMissToken && v == "" {
				return false
			}

			if strings.Contains(req.URL.Path, "/v1/health") {
				return false
			}
			return true
		},
		Realm: "servicecomb-kie-realm",
		SecretFunc: func(claims interface{}, method token.SigningMethod) (interface{}, error) {
			p, err := secret.ParseRSAPPublicKey(PublicKey())
			if err != nil {
				openlog.Error("can not parse public key:" + err.Error())
				return nil, err
			}
			return p, nil
		},
	})
	loadPublicKey()
	openlog.Info("rbac is enabled")
}