code.gitea.io/gitea@v1.19.3/modules/auth/openid/openid.go (about) 1 // Copyright 2017 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package openid 5 6 import ( 7 "time" 8 9 "github.com/yohcop/openid-go" 10 ) 11 12 // For the demo, we use in-memory infinite storage nonce and discovery 13 // cache. In your app, do not use this as it will eat up memory and 14 // never 15 // free it. Use your own implementation, on a better database system. 16 // If you have multiple servers for example, you may need to share at 17 // least 18 // the nonceStore between them. 19 var ( 20 nonceStore = openid.NewSimpleNonceStore() 21 discoveryCache = newTimedDiscoveryCache(24 * time.Hour) 22 ) 23 24 // Verify handles response from OpenID provider 25 func Verify(fullURL string) (id string, err error) { 26 return openid.Verify(fullURL, discoveryCache, nonceStore) 27 } 28 29 // Normalize normalizes an OpenID URI 30 func Normalize(url string) (id string, err error) { 31 return openid.Normalize(url) 32 } 33 34 // RedirectURL redirects browser 35 func RedirectURL(id, callbackURL, realm string) (string, error) { 36 return openid.RedirectURL(id, callbackURL, realm) 37 }