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 ( ...@@ -18,10 +18,10 @@ var (
) )
type AccessKey struct { type AccessKey struct {
Id string Id string
Secret string Secret string
Path string Path string
Context string Value string
} }
func (ak AccessKey) Sign() string { func (ak AccessKey) Sign() string {
...@@ -35,7 +35,7 @@ func (ak *AccessKey) LoadAccessKeyFromStr(key string) error { ...@@ -35,7 +35,7 @@ func (ak *AccessKey) LoadAccessKeyFromStr(key string) error {
return AccessKeyNotFound return AccessKeyNotFound
} }
keySlice := strings.Split(strings.TrimSpace(key), ":") keySlice := strings.Split(strings.TrimSpace(key), ":")
if len(ak.Context) != 2 { if len(ak.Value) != 2 {
return AccessKeyInvalid return AccessKeyInvalid
} }
ak.Id = keySlice[0] ak.Id = keySlice[0]
...@@ -69,7 +69,7 @@ func (ak *AccessKey) Register(times int) error { ...@@ -69,7 +69,7 @@ func (ak *AccessKey) Register(times int) error {
// LoadAccessKey 加载AccessKey用来与 Core Api 交互 // LoadAccessKey 加载AccessKey用来与 Core Api 交互
func (ak *AccessKey) Load() (err error) { func (ak *AccessKey) Load() (err error) {
err = ak.LoadAccessKeyFromStr(ak.Context) err = ak.LoadAccessKeyFromStr(ak.Value)
if err == nil { if err == nil {
return return
} }
......
...@@ -51,7 +51,7 @@ func (c *WrapperClient) LoadAuth() error { ...@@ -51,7 +51,7 @@ func (c *WrapperClient) LoadAuth() error {
if !path.IsAbs(config.Conf.AccessKeyFile) { if !path.IsAbs(config.Conf.AccessKeyFile) {
keyPath = filepath.Join(config.Conf.RootPath, keyPath) 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() err := ak.Load()
if err != nil { if err != nil {
return err return err
......
...@@ -53,7 +53,7 @@ package service ...@@ -53,7 +53,7 @@ package service
// return result.User, nil // 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() // username := ctx.User()
// remoteAddr := ctx.RemoteAddr().String() // 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