Commit 17a481d4 authored by ibuler's avatar ibuler

[Update] 修改

parent 077c1b7f
package auth
import (
"cocogo/pkg/config"
)
var appService *Service
func Initial() {
conf := config.GetGlobalConfig()
appService = NewAuthService(conf)
appService.LoadAccessKey()
appService.EnsureValidAuth()
appService.LoadTerminalConfig()
}
func GetGlobalService() *Service {
if appService == nil {
Initial()
}
return appService
}
......@@ -18,10 +18,10 @@ var (
)
type AccessKey struct {
Id string
Secret string
Path string
Context string
Id string
Secret string
Path string
Value string
}
func (ak AccessKey) Sign() string {
......@@ -35,7 +35,7 @@ func (ak *AccessKey) LoadAccessKeyFromStr(key string) error {
return AccessKeyNotFound
}
keySlice := strings.Split(strings.TrimSpace(key), ":")
if len(ak.Context) != 2 {
if len(ak.Value) != 2 {
return AccessKeyInvalid
}
ak.Id = keySlice[0]
......@@ -69,7 +69,7 @@ func (ak *AccessKey) Register(times int) error {
// LoadAccessKey 加载AccessKey用来与 Core Api 交互
func (ak *AccessKey) Load() (err error) {
err = ak.LoadAccessKeyFromStr(ak.Context)
err = ak.LoadAccessKeyFromStr(ak.Value)
if err == nil {
return
}
......
......@@ -51,7 +51,7 @@ func (c *WrapperClient) LoadAuth() error {
if !path.IsAbs(config.Conf.AccessKeyFile) {
keyPath = filepath.Join(config.Conf.RootPath, keyPath)
}
ak := AccessKey{Context: config.Conf.AccessKey, Path: keyPath}
ak := AccessKey{Value: config.Conf.AccessKey, Path: keyPath}
err := ak.Load()
if err != nil {
return err
......
......@@ -53,7 +53,7 @@ package service
// return result.User, nil
//}
//
//func (s *Service) CheckSSHPassword(ctx ssh.Context, password string) bool {
//func (s *Service) CheckSSHPassword(ctx ssh.Value, password string) bool {
//
// username := ctx.User()
// remoteAddr := ctx.RemoteAddr().String()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment