You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

openid.go 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  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. }