haiwai-common-sdk-go/services/sso/url.go

28 lines
793 B
Go
Raw Normal View History

2023-06-20 14:30:38 +08:00
package sso
import (
"fmt"
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
"net/url"
"strings"
)
func GetLoginUrl(ident string, redirectUrl string, env ...string) string {
uri := fmt.Sprintf("/admin/main/login?ident=%s&redirectUrl=%s", ident, url.QueryEscape(redirectUrl))
scheme, host := getSchemeAndHost(env...)
return fmt.Sprintf("%s://%s%s", scheme, host, uri)
}
2023-06-20 14:50:16 +08:00
func GetLogoutUrl(ident string, env ...string) string {
2023-06-20 14:30:38 +08:00
uri := fmt.Sprintf("/admin/main/logout?ident=%s&redirectUrl=", ident)
scheme, host := getSchemeAndHost(env...)
return fmt.Sprintf("%s://%s%s", scheme, host, uri)
}
func getSchemeAndHost(env ...string) (scheme, host string) {
env = append(env, requests.RELEASE)
host = HOST.Func(env[0], "")
scheme = strings.ToLower(requests.HTTPS)
return
}