deploy adjust
This commit is contained in:
parent
3d42ce6820
commit
d83208be52
11
Makefile
11
Makefile
@ -21,15 +21,20 @@ clean:
|
|||||||
rm -rf oc-auth oc-auth.tar.gz
|
rm -rf oc-auth oc-auth.tar.gz
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
DOCKER_BUILDKIT=1 docker build -t oc/oc-auth:0.0.1 -f Dockerfile .
|
DOCKER_BUILDKIT=1 docker build -t oc-auth -f Dockerfile . --build-arg=HOST=$(HOST)
|
||||||
docker tag oc/oc-auth:0.0.1 oc/oc-auth:latest
|
docker tag oc-auth:latest oc/oc-auth:0.0.1
|
||||||
|
|
||||||
publish-kind:
|
publish-kind:
|
||||||
kind load docker-image oc/oc-auth:0.0.1 --name opencloud
|
kind load docker-image oc/oc-auth:0.0.1 --name opencloud | true
|
||||||
|
|
||||||
publish-registry:
|
publish-registry:
|
||||||
@echo "TODO"
|
@echo "TODO"
|
||||||
|
|
||||||
|
docker-deploy:
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
run-docker: docker publish-kind publish-registry docker-deploy
|
||||||
|
|
||||||
all: docker publish-kind publish-registry
|
all: docker publish-kind publish-registry
|
||||||
|
|
||||||
.PHONY: build run clean docker publish-kind publish-registry
|
.PHONY: build run clean docker publish-kind publish-registry
|
||||||
|
@ -22,12 +22,12 @@ type Config struct {
|
|||||||
AuthConnectPublicHost string
|
AuthConnectPublicHost string
|
||||||
AuthConnectorHost string
|
AuthConnectorHost string
|
||||||
AuthConnectorPort int
|
AuthConnectorPort int
|
||||||
AuthConnectorAdminPort int
|
AuthConnectorAdminPort string
|
||||||
|
|
||||||
PermissionConnectorWriteHost string
|
PermissionConnectorWriteHost string
|
||||||
PermissionConnectorReadHost string
|
PermissionConnectorReadHost string
|
||||||
PermissionConnectorPort int
|
PermissionConnectorPort string
|
||||||
PermissionConnectorAdminPort int
|
PermissionConnectorAdminPort string
|
||||||
|
|
||||||
Local bool
|
Local bool
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@ func (o *OAuthController) Login() {
|
|||||||
if conf.GetConfig().SourceMode == "ldap" {
|
if conf.GetConfig().SourceMode == "ldap" {
|
||||||
ldap := auth_connectors.New()
|
ldap := auth_connectors.New()
|
||||||
found, err := ldap.Authenticate(o.Ctx.Request.Context(), res.Username, res.Password)
|
found, err := ldap.Authenticate(o.Ctx.Request.Context(), res.Username, res.Password)
|
||||||
|
fmt.Println("login", clientID, found, err)
|
||||||
if err != nil || !found {
|
if err != nil || !found {
|
||||||
o.Data["json"] = err
|
o.Data["json"] = err
|
||||||
o.Ctx.ResponseWriter.WriteHeader(401)
|
o.Ctx.ResponseWriter.WriteHeader(401)
|
||||||
@ -84,6 +85,7 @@ func (o *OAuthController) Login() {
|
|||||||
Name: "csrf_token",
|
Name: "csrf_token",
|
||||||
Value: o.XSRFToken(),
|
Value: o.XSRFToken(),
|
||||||
})
|
})
|
||||||
|
fmt.Println("login token", token, err)
|
||||||
if err != nil || token == nil {
|
if err != nil || token == nil {
|
||||||
o.Data["json"] = err
|
o.Data["json"] = err
|
||||||
o.Ctx.ResponseWriter.WriteHeader(401)
|
o.Ctx.ResponseWriter.WriteHeader(401)
|
||||||
|
4
env.env
Normal file
4
env.env
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
KUBERNETES_SERVICE_HOST=192.168.47.20
|
||||||
|
KUBE_CA="LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkekNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUzTWpNeE1USXdNell3SGhjTk1qUXdPREE0TVRBeE16VTJXaGNOTXpRd09EQTJNVEF4TXpVMgpXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUzTWpNeE1USXdNell3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFTVlk3ZHZhNEdYT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09TNFE5VTlvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFVUozblJZN0tCNEtUWUx0WnFUMS96VS84a0Z2Sk1lUGhYMm1Vc25pczBiR3FZblkyaVZEeApYVzR2SVhTYjNqcm9iZ1YwSUtDT0twUWs2OHJEbE03ckRBPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo="
|
@ -31,7 +31,7 @@ type HydraConnector struct {
|
|||||||
func (a HydraConnector) Status() tools.State {
|
func (a HydraConnector) Status() tools.State {
|
||||||
caller := tools.NewHTTPCaller(map[tools.DataType]map[tools.METHOD]string{})
|
caller := tools.NewHTTPCaller(map[tools.DataType]map[tools.METHOD]string{})
|
||||||
var responseBody map[string]interface{}
|
var responseBody map[string]interface{}
|
||||||
host := conf.GetConfig().AuthConnectorHost
|
host := conf.GetConfig().AuthConnectPublicHost
|
||||||
if conf.GetConfig().Local {
|
if conf.GetConfig().Local {
|
||||||
host = "localhost"
|
host = "localhost"
|
||||||
}
|
}
|
||||||
@ -80,6 +80,7 @@ func (a HydraConnector) challenge(username string, url string, challenge string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, s[1], cookies, err
|
return nil, s[1], cookies, err
|
||||||
}
|
}
|
||||||
|
fmt.Println(string(b))
|
||||||
var token Redirect
|
var token Redirect
|
||||||
err = json.Unmarshal(b, &token)
|
err = json.Unmarshal(b, &token)
|
||||||
if err != nil {
|
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 {
|
func (a HydraConnector) getClient(clientID string) string {
|
||||||
resp, err := a.Caller.CallGet(a.getPath(true, false), "/clients")
|
resp, err := a.Caller.CallGet(a.getPath(true, false), "/clients")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
var clients []interface{}
|
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) {
|
func (a HydraConnector) Login(clientID string, username string, cookies ...*http.Cookie) (t *Token, err error) {
|
||||||
clientID = a.getClient(clientID)
|
clientID = a.getClient(clientID)
|
||||||
|
if clientID == "" {
|
||||||
|
return nil, errors.New("no client found")
|
||||||
|
}
|
||||||
redirect, _, cookies, err := a.tryLog(username, a.getPath(false, true),
|
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,
|
"/auth?client_id="+clientID+"&response_type="+strings.ReplaceAll(a.ResponseType, " ", "%20")+"&scope="+strings.ReplaceAll(a.Scopes, " ", "%20")+"&state="+a.State,
|
||||||
"login", cookies...)
|
"login", cookies...)
|
||||||
fmt.Println("login", clientID, username, a.getPath(false, true), redirect, err)
|
|
||||||
if err != nil || redirect == nil {
|
if err != nil || redirect == nil {
|
||||||
|
if redirect == nil {
|
||||||
|
return nil, errors.New("no oauth redirection " + clientID)
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
redirect, _, cookies, err = a.tryLog(username, a.urlFormat(redirect.RedirectTo, a.getPath(false, true)), "", "consent", cookies...)
|
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{}
|
var m map[string]interface{}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
b, err := io.ReadAll(resp.Body)
|
b, err := io.ReadAll(resp.Body)
|
||||||
|
fmt.Println("login", b, err, a.getPath(false, true), "/token")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(b, &token)
|
err = json.Unmarshal(b, &token)
|
||||||
|
fmt.Println("login2", token, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 {
|
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 {
|
if conf.GetConfig().Local {
|
||||||
host = "localhost"
|
host = "localhost"
|
||||||
}
|
}
|
||||||
port := fmt.Sprintf("%v", conf.GetConfig().AuthConnectorPort)
|
port := fmt.Sprintf("%v", conf.GetConfig().AuthConnectorPort)
|
||||||
if isAdmin {
|
if isAdmin {
|
||||||
port = fmt.Sprintf("%v", conf.GetConfig().AuthConnectorAdminPort) + "/admin"
|
port = fmt.Sprintf("%v", conf.GetConfig().AuthConnectorAdminPort)
|
||||||
}
|
}
|
||||||
oauth := ""
|
oauth := ""
|
||||||
if isOauth {
|
if isOauth {
|
||||||
|
6
main.go
6
main.go
@ -43,11 +43,11 @@ func main() {
|
|||||||
conf.GetConfig().AuthConnectorHost = o.GetStringDefault("AUTH_CONNECTOR_HOST", "localhost")
|
conf.GetConfig().AuthConnectorHost = o.GetStringDefault("AUTH_CONNECTOR_HOST", "localhost")
|
||||||
conf.GetConfig().AuthConnectPublicHost = o.GetStringDefault("AUTH_CONNECTOR_PUBLIC_HOST", "localhost")
|
conf.GetConfig().AuthConnectPublicHost = o.GetStringDefault("AUTH_CONNECTOR_PUBLIC_HOST", "localhost")
|
||||||
conf.GetConfig().AuthConnectorPort = o.GetIntDefault("AUTH_CONNECTOR_PORT", 4444)
|
conf.GetConfig().AuthConnectorPort = o.GetIntDefault("AUTH_CONNECTOR_PORT", 4444)
|
||||||
conf.GetConfig().AuthConnectorAdminPort = o.GetIntDefault("AUTH_CONNECTOR_ADMIN_PORT", 4445)
|
conf.GetConfig().AuthConnectorAdminPort = o.GetStringDefault("AUTH_CONNECTOR_ADMIN_PORT", "4445/admin")
|
||||||
conf.GetConfig().PermissionConnectorWriteHost = o.GetStringDefault("PERMISSION_CONNECTOR_WRITE_HOST", "keto")
|
conf.GetConfig().PermissionConnectorWriteHost = o.GetStringDefault("PERMISSION_CONNECTOR_WRITE_HOST", "keto")
|
||||||
conf.GetConfig().PermissionConnectorReadHost = o.GetStringDefault("PERMISSION_CONNECTOR_READ_HOST", "keto")
|
conf.GetConfig().PermissionConnectorReadHost = o.GetStringDefault("PERMISSION_CONNECTOR_READ_HOST", "keto")
|
||||||
conf.GetConfig().PermissionConnectorPort = o.GetIntDefault("PERMISSION_CONNECTOR_PORT", 4466)
|
conf.GetConfig().PermissionConnectorPort = o.GetStringDefault("PERMISSION_CONNECTOR_PORT", "4466")
|
||||||
conf.GetConfig().PermissionConnectorAdminPort = o.GetIntDefault("PERMISSION_CONNECTOR_ADMIN_PORT", 4467)
|
conf.GetConfig().PermissionConnectorAdminPort = o.GetStringDefault("PERMISSION_CONNECTOR_ADMIN_PORT", "4467")
|
||||||
conf.GetConfig().Local = o.GetBoolDefault("LOCAL", true)
|
conf.GetConfig().Local = o.GetBoolDefault("LOCAL", true)
|
||||||
|
|
||||||
// config LDAP
|
// config LDAP
|
||||||
|
Loading…
Reference in New Issue
Block a user