MCPcopy Create free account
hub / github.com/Scalingo/cli / RemoveAuth

Method RemoveAuth

config/auth.go:171–197  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

169}
170
171func (a *CliAuthenticator) RemoveAuth(ctx context.Context) error {
172 authConfig, err := existingAuth(ctx)
173 if err != nil {
174 return errors.Wrapf(ctx, err, "get authentication config for removal")
175 }
176
177 var c auth.ConfigPerHostV2
178 err = json.Unmarshal(authConfig.AuthConfigPerHost, &c)
179 if err != nil {
180 return errors.Wrapf(ctx, err, "unmarshal authentication config per host")
181 }
182
183 authHost, err := a.authHost(ctx)
184 if err != nil {
185 return errors.Wrapf(ctx, err, "get authentication service host")
186 }
187
188 delete(c, authHost)
189
190 buffer, err := json.Marshal(&c)
191 if err != nil {
192 return errors.Wrapf(ctx, err, "marshal cleaned authentication config")
193 }
194
195 authConfig.AuthConfigPerHost = json.RawMessage(buffer)
196 return writeAuthFile(ctx, authConfig)
197}
198
199func (a *CliAuthenticator) authHost(ctx context.Context) (string, error) {
200 u, err := url.Parse(C.ScalingoAuthURL)

Callers 1

DestroyTokenFunction · 0.95

Calls 3

authHostMethod · 0.95
existingAuthFunction · 0.85
writeAuthFileFunction · 0.85

Tested by

no test coverage detected