本站源代码
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

37 lines
1.1KB

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package openid
  5. import (
  6. "time"
  7. "github.com/yohcop/openid-go"
  8. )
  9. // For the demo, we use in-memory infinite storage nonce and discovery
  10. // cache. In your app, do not use this as it will eat up memory and
  11. // never
  12. // free it. Use your own implementation, on a better database system.
  13. // If you have multiple servers for example, you may need to share at
  14. // least
  15. // the nonceStore between them.
  16. var nonceStore = openid.NewSimpleNonceStore()
  17. var discoveryCache = newTimedDiscoveryCache(24 * time.Hour)
  18. // Verify handles response from OpenID provider
  19. func Verify(fullURL string) (id string, err error) {
  20. return openid.Verify(fullURL, discoveryCache, nonceStore)
  21. }
  22. // Normalize normalizes an OpenID URI
  23. func Normalize(url string) (id string, err error) {
  24. return openid.Normalize(url)
  25. }
  26. // RedirectURL redirects browser
  27. func RedirectURL(id, callbackURL, realm string) (string, error) {
  28. return openid.RedirectURL(id, callbackURL, realm)
  29. }
上海开阖软件有限公司 沪ICP备12045867号-1