deploy adjust
This commit is contained in:
@@ -31,7 +31,7 @@ type HydraConnector struct {
|
||||
func (a HydraConnector) Status() tools.State {
|
||||
caller := tools.NewHTTPCaller(map[tools.DataType]map[tools.METHOD]string{})
|
||||
var responseBody map[string]interface{}
|
||||
host := conf.GetConfig().AuthConnectorHost
|
||||
host := conf.GetConfig().AuthConnectPublicHost
|
||||
if conf.GetConfig().Local {
|
||||
host = "localhost"
|
||||
}
|
||||
@@ -80,6 +80,7 @@ func (a HydraConnector) challenge(username string, url string, challenge string,
|
||||
if err != nil {
|
||||
return nil, s[1], cookies, err
|
||||
}
|
||||
fmt.Println(string(b))
|
||||
var token Redirect
|
||||
err = json.Unmarshal(b, &token)
|
||||
if err != nil {
|
||||
@@ -126,6 +127,7 @@ func (a HydraConnector) tryLog(username string, url string, subpath string, chal
|
||||
func (a HydraConnector) getClient(clientID string) string {
|
||||
resp, err := a.Caller.CallGet(a.getPath(true, false), "/clients")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return ""
|
||||
}
|
||||
var clients []interface{}
|
||||
@@ -143,11 +145,16 @@ func (a HydraConnector) getClient(clientID string) string {
|
||||
|
||||
func (a HydraConnector) Login(clientID string, username string, cookies ...*http.Cookie) (t *Token, err error) {
|
||||
clientID = a.getClient(clientID)
|
||||
if clientID == "" {
|
||||
return nil, errors.New("no client found")
|
||||
}
|
||||
redirect, _, cookies, err := a.tryLog(username, a.getPath(false, true),
|
||||
"/auth?client_id="+clientID+"&response_type="+strings.ReplaceAll(a.ResponseType, " ", "%20")+"&scope="+strings.ReplaceAll(a.Scopes, " ", "%20")+"&state="+a.State,
|
||||
"login", cookies...)
|
||||
fmt.Println("login", clientID, username, a.getPath(false, true), redirect, err)
|
||||
if err != nil || redirect == nil {
|
||||
if redirect == nil {
|
||||
return nil, errors.New("no oauth redirection " + clientID)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
redirect, _, cookies, err = a.tryLog(username, a.urlFormat(redirect.RedirectTo, a.getPath(false, true)), "", "consent", cookies...)
|
||||
@@ -177,10 +184,12 @@ func (a HydraConnector) Login(clientID string, username string, cookies ...*http
|
||||
var m map[string]interface{}
|
||||
defer resp.Body.Close()
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
fmt.Println("login", b, err, a.getPath(false, true), "/token")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = json.Unmarshal(b, &token)
|
||||
fmt.Println("login2", token, err)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -252,13 +261,16 @@ func (a HydraConnector) Introspect(token string, cookie ...*http.Cookie) (bool,
|
||||
}
|
||||
|
||||
func (a HydraConnector) getPath(isAdmin bool, isOauth bool) string {
|
||||
host := conf.GetConfig().AuthConnectorHost
|
||||
host := conf.GetConfig().AuthConnectPublicHost
|
||||
if isAdmin {
|
||||
host = conf.GetConfig().AuthConnectorHost
|
||||
}
|
||||
if conf.GetConfig().Local {
|
||||
host = "localhost"
|
||||
}
|
||||
port := fmt.Sprintf("%v", conf.GetConfig().AuthConnectorPort)
|
||||
if isAdmin {
|
||||
port = fmt.Sprintf("%v", conf.GetConfig().AuthConnectorAdminPort) + "/admin"
|
||||
port = fmt.Sprintf("%v", conf.GetConfig().AuthConnectorAdminPort)
|
||||
}
|
||||
oauth := ""
|
||||
if isOauth {
|
||||
|
||||
Reference in New Issue
Block a user