// DeleteToken deletes a given provisioning token on the auth server (CA). It
// could be a user token or a machine token
500896
func (c *Client) DeleteToken(token string) error {
	_, err := c.Delete(c.Endpoint("tokens", token))
	return trace.Wrap(err)
}
305567
func (s *Service) DeleteBucket(ctx context.Context, id platform.ID) error {
	if _, err := s.FindBucketByID(ctx, id); err != nil {
		return &platform.Error{
			Op:  OpPrefix + platform.OpDeleteBucket,
			Err: err,
		}
	}
	s.bucketKV.Delete(id.String())

	// return s.deleteLabel(ctx, platform.LabelFilter{ResourceID: id})
	return nil
}
280941
func (c *DiskTokenCache) DeleteToken(key *CacheKey) error {
	return c.updateCacheFile(func(cache *cacheFile, now time.Time) bool {
		for i, entry := range cache.Cache {
			if EqualCacheKeys(&entry.Key, key) {
				cache.Cache = append(cache.Cache[:i], cache.Cache[i+1:]...)
				return true
			}
		}
		return false // not there, this is fine, skip writing the file
	})
}
906730
func (c *FakeOAuthAccessTokens) Delete(name string, options *v1.DeleteOptions) error {
	_, err := c.Fake.
		Invokes(testing.NewRootDeleteAction(oauthaccesstokensResource, name), &oauth.OAuthAccessToken{})
	return err
}
1007544
func (s *PresenceService) DeleteAuthServer(name string) error {
	key := backend.Key(authServersPrefix, name)
	return s.Delete(context.TODO(), key)
}
393417
func (c *Client) DeleteStaticTokens() error {
	_, err := c.Delete(c.Endpoint("configuration", "static_tokens"))
	return trace.Wrap(err)
}
471945
func (s *authKeyV1) Delete() interface{} {
	var handler AuthDeleteHandler = func(params martini.Params, log *log.Logger, r render.Render, tokens oauth2.Tokens) {
		var err error
		username := params[UserParam]
		log.Println("deleting apikey for: ", username)
		userInfo := GetUserInfo(tokens)

		NewUserMatch().
			UserInfo(userInfo).
			UserName(username).
			OnSuccess(func() {

			if err = s.keyGen.Delete(username); err == nil {
				log.Println("key deleted for: ", username)

			} else {
				log.Println("key delete failed: ", username, err.Error())
			}
		}).
			OnFailure(func() {
			err = ErrInvalidCallerEmail
			log.Println("invalid user token error: ", err)
		}).Run()

		genericResponseFormatter(r, "", userInfo, err)
	}
	return handler
}
386145
func (s *AuthorizationService) DeleteAuthorization(ctx context.Context, id platform.ID) error {
	return s.DeleteAuthorizationFn(ctx, id)
}
862099
func (r *sessionRepository) DeleteByOwnerToken(ctx context.Context, ownerToken string) ([]sessions.Session, error) {
	conn := r.pool.Get()
	defer conn.Close()

	deleted := []sessions.Session{}
	ownerSessionsKey := ownerSessionsKey(ownerToken)
	sessionKeys, err := redigo.Values(conn.Do("HKEYS", ownerSessionsKey))
	if err != nil {
		return nil, errors.Wrap(err, "could not get the ownerToken index")
	}
	if sessionKeys == nil || len(sessionKeys) == 0 {
		return deleted, nil
	}
	vals, err := redigo.ByteSlices(conn.Do("MGET", sessionKeys...))
	if err != nil {
		return nil, errors.Wrap(err, "could not get the sessions by ownerToken")
	}
	for _, val := range vals {
		session := sessions.Session{}
		if err := json.Unmarshal(val, &session); err != nil {
			return nil, errors.Wrap(err, "found session unmarshalling failed")
		}
		deleted = append(deleted, session)
	}
	if _, err := redigo.Int(conn.Do("DEL", append([]interface{}{ownerSessionsKey}, sessionKeys...)...)); err != nil {
		return nil, errors.Wrap(err, "could not delete the sessions by ownerToken")
	}
	return deleted, nil
}
603398
func (c Claims) Del(key string) {
	jwt.Claims(c).Del(key)
}
174009
func (t *Store) UserToken() string {
	t.l.RLock()
	defer t.l.RUnlock()

	return t.userToken
}
157954
func (c *Client) GetToken(token string) (services.ProvisionToken, error) {
	out, err := c.Get(c.Endpoint("tokens", token), url.Values{})
	if err != nil {
		return nil, trace.Wrap(err)
	}
	return services.UnmarshalProvisionToken(out.Bytes(), services.SkipValidation())
}
906273
func (c *TokenCommand) Del(client auth.ClientI) error {
	if c.value == "" {
		return trace.Errorf("Need an argument: token")
	}
	if err := client.DeleteToken(c.value); err != nil {
		return trace.Wrap(err)
	}
	fmt.Printf("Token %s has been deleted\n", c.value)
	return nil
}
1044719
func (c *oAuthClientAuthorizations) Delete(name string, options *v1.DeleteOptions) error {
	return c.client.Delete().
		Resource("oauthclientauthorizations").
		Name(name).
		Body(options).
		Do().
		Error()
}
972927
func (s *AuthServer) GenerateToken(req GenerateTokenRequest) (string, error) {
	if err := req.CheckAndSetDefaults(); err != nil {
		return "", trace.Wrap(err)
	}
	token, err := services.NewProvisionToken(req.Token, req.Roles, s.clock.Now().UTC().Add(req.TTL))
	if err != nil {
		return "", trace.Wrap(err)
	}
	if err := s.Provisioner.UpsertToken(token); err != nil {
		return "", trace.Wrap(err)
	}
	return req.Token, nil
}
779623
func (s *PresenceService) DeleteAllAuthServers() error {
	startKey := backend.Key(authServersPrefix)
	return s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
}
253176
func (t *apidTokenManager) invalidateToken() {
	log.Debug("invalidating token")
	t.invalidateTokenChan <- true
	<-t.invalidateDone
}