當前位置: 首頁>>代碼示例>>Golang>>正文


Golang logical.RenewAuthRequest函數代碼示例

本文整理匯總了Golang中github.com/hashicorp/vault/logical.RenewAuthRequest函數的典型用法代碼示例。如果您正苦於以下問題:Golang RenewAuthRequest函數的具體用法?Golang RenewAuthRequest怎麽用?Golang RenewAuthRequest使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了RenewAuthRequest函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestBackendHandleRequest_renewAuth

func TestBackendHandleRequest_renewAuth(t *testing.T) {
	b := &Backend{}

	resp, err := b.HandleRequest(logical.RenewAuthRequest(
		"/foo", &logical.Auth{}, nil))
	if err != nil {
		t.Fatalf("err: %s", err)
	}
	if !resp.IsError() {
		t.Fatalf("bad: %#v", resp)
	}
}
開發者ID:beornf,項目名稱:vault,代碼行數:12,代碼來源:backend_test.go

示例2: renewAuthEntry

// renewAuthEntry is used to attempt renew of an auth entry
func (m *ExpirationManager) renewAuthEntry(le *leaseEntry, increment time.Duration) (*logical.Response, error) {
	auth := *le.Auth
	auth.LeaseIssue = le.IssueTime
	auth.LeaseIncrement = increment
	auth.ClientToken = ""

	req := logical.RenewAuthRequest(le.Path, &auth, nil)
	resp, err := m.router.Route(req)
	if err != nil {
		return nil, fmt.Errorf("failed to renew entry: %v", err)
	}
	return resp, nil
}
開發者ID:theonewolf,項目名稱:vault,代碼行數:14,代碼來源:expiration.go

示例3: renewAuthEntry

// renewAuthEntry is used to attempt renew of an auth entry. Only the token
// store should get the actual token ID intact.
func (m *ExpirationManager) renewAuthEntry(req *logical.Request, le *leaseEntry, increment time.Duration) (*logical.Response, error) {
	auth := *le.Auth
	auth.IssueTime = le.IssueTime
	auth.Increment = increment
	if strings.HasPrefix(le.Path, "auth/token/") {
		auth.ClientToken = le.ClientToken
	} else {
		auth.ClientToken = ""
	}

	authReq := logical.RenewAuthRequest(le.Path, &auth, nil)
	authReq.Connection = req.Connection
	resp, err := m.router.Route(authReq)
	if err != nil {
		return nil, fmt.Errorf("failed to renew entry: %v", err)
	}
	return resp, nil
}
開發者ID:rchicoli,項目名稱:consul-template,代碼行數:20,代碼來源:expiration.go

示例4: TestBackendHandleRequest_renewAuthCallback

func TestBackendHandleRequest_renewAuthCallback(t *testing.T) {
	var called uint32
	callback := func(*logical.Request, *FieldData) (*logical.Response, error) {
		atomic.AddUint32(&called, 1)
		return nil, nil
	}

	b := &Backend{
		AuthRenew: callback,
	}

	_, err := b.HandleRequest(logical.RenewAuthRequest(
		"/foo", &logical.Auth{}, nil))
	if err != nil {
		t.Fatalf("err: %s", err)
	}
	if v := atomic.LoadUint32(&called); v != 1 {
		t.Fatalf("bad: %#v", v)
	}
}
開發者ID:beornf,項目名稱:vault,代碼行數:20,代碼來源:backend_test.go


注:本文中的github.com/hashicorp/vault/logical.RenewAuthRequest函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。