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 15:54:22 +08:00
|
|
|
func GetLogoutUrl(ident string, redirectUrl string, env ...string) string {
|
|
|
|
uri := fmt.Sprintf("/admin/main/loginOut?ident=%s&redirectUrl=%s", ident, url.QueryEscape(redirectUrl))
|
2023-06-20 14:30:38 +08:00
|
|
|
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
|
|
|
|
}
|