|
|
@@ -2,7 +2,6 @@ package sso |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"fmt" |
|
|
"fmt" |
|
|
"gitlink.org.cn/cloudream/common/consts/errorcode" |
|
|
|
|
|
"gitlink.org.cn/cloudream/common/utils/http2" |
|
|
"gitlink.org.cn/cloudream/common/utils/http2" |
|
|
"gitlink.org.cn/cloudream/common/utils/serder" |
|
|
"gitlink.org.cn/cloudream/common/utils/serder" |
|
|
"net/url" |
|
|
"net/url" |
|
|
@@ -14,6 +13,7 @@ type SSOInfoResp struct { |
|
|
Roles []string `json:"roles"` |
|
|
Roles []string `json:"roles"` |
|
|
ID string `json:"id"` |
|
|
ID string `json:"id"` |
|
|
Username string `json:"username"` |
|
|
Username string `json:"username"` |
|
|
|
|
|
Menus []any `json:"menus"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *Client) GetSSOInfo(token string) (*SSOInfoResp, error) { |
|
|
func (c *Client) GetSSOInfo(token string) (*SSOInfoResp, error) { |
|
|
@@ -33,6 +33,11 @@ func (c *Client) GetSSOInfo(token string) (*SSOInfoResp, error) { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//all, err := io.ReadAll(resp.Body) |
|
|
|
|
|
//println("output: ") |
|
|
|
|
|
//str := string(all) |
|
|
|
|
|
//println(str) |
|
|
|
|
|
|
|
|
contType := resp.Header.Get("Content-Type") |
|
|
contType := resp.Header.Get("Content-Type") |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
if strings.Contains(contType, http2.ContentTypeJSON) { |
|
|
var codeResp response[SSOInfoResp] |
|
|
var codeResp response[SSOInfoResp] |
|
|
@@ -40,7 +45,7 @@ func (c *Client) GetSSOInfo(token string) (*SSOInfoResp, error) { |
|
|
return nil, fmt.Errorf("parsing response: %w", err) |
|
|
return nil, fmt.Errorf("parsing response: %w", err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if codeResp.Code == errorcode.OK { |
|
|
|
|
|
|
|
|
if codeResp.Code == ResponseCodeOK { |
|
|
return &codeResp.Data, nil |
|
|
return &codeResp.Data, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|