MCPcopy Create free account
hub / github.com/Mister-leo/fssh / SaveMode

Function SaveMode

internal/auth/auth.go:113–139  ·  view source on GitHub ↗

SaveMode 保存认证模式

(mode AuthMode)

Source from the content-addressed store, hash-verified

111
112// SaveMode 保存认证模式
113func SaveMode(mode AuthMode) error {
114 path := modeConfigPath()
115
116 cfg := modeConfig{
117 Version: "fssh-auth/v1",
118 Mode: mode,
119 CreatedAt: time.Now().Format(time.RFC3339),
120 }
121
122 data, err := json.MarshalIndent(cfg, "", " ")
123 if err != nil {
124 return fmt.Errorf("序列化认证模式配置失败: %w", err)
125 }
126
127 // 确保目录存在
128 dir := filepath.Dir(path)
129 if err := os.MkdirAll(dir, 0700); err != nil {
130 return fmt.Errorf("创建配置目录失败: %w", err)
131 }
132
133 // 写入文件
134 if err := os.WriteFile(path, data, 0644); err != nil {
135 return fmt.Errorf("保存认证模式配置失败: %w", err)
136 }
137
138 return nil
139}
140
141// modeConfigPath 返回认证模式配置文件路径
142func modeConfigPath() string {

Callers 2

initOTPModeFunction · 0.92
initTouchIDModeFunction · 0.92

Calls 1

modeConfigPathFunction · 0.85

Tested by

no test coverage detected