casual debug for claims

This commit is contained in:
mr 2024-10-30 17:05:12 +01:00
parent 2ca16c07b3
commit 02767d87fa
3 changed files with 11 additions and 8 deletions

View File

@ -7,12 +7,14 @@ services:
networks: networks:
- catalog - catalog
command: command:
- "--api.insecure=true"
- "--providers.docker=true" - "--providers.docker=true"
- "--providers.docker.exposedbydefault=false" - "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80" - "--entrypoints.web.address=:80"
- "--log.level=DEBUG" - "--log.level=DEBUG"
ports: ports:
- "8080:80" - "8080:80"
- "8082:8080"
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
whoami: # TEST PURPOSE whoami: # TEST PURPOSE
@ -24,11 +26,11 @@ services:
- "5000:80" - "5000:80"
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.obg.entrypoints=web" - "traefik.http.routers.whoami.entrypoints=web"
- "traefik.http.routers.obg.rule=Host(`localhost`)" - "traefik.http.routers.whoami.rule=Host(`localhost`)"
- "traefik.http.routers.obg.tls=false" - "traefik.http.routers.whoami.tls=false"
- "traefik.http.services.obg.loadbalancer.server.port=80" - "traefik.http.services.whoami.loadbalancer.server.port=80"
- "traefik.http.routers.obg.middlewares=oc-auth" - "traefik.http.routers.whoami.middlewares=auth"
oc-auth: oc-auth:
image: 'oc-auth:latest' image: 'oc-auth:latest'
ports: ports:

View File

@ -11,6 +11,7 @@ import (
"oc-auth/conf" "oc-auth/conf"
"oc-auth/infrastructure/claims" "oc-auth/infrastructure/claims"
"regexp" "regexp"
"strconv"
"strings" "strings"
oclib "cloud.o-forge.io/core/oc-lib" oclib "cloud.o-forge.io/core/oc-lib"
@ -174,7 +175,7 @@ func (a HydraConnector) Login(username string, cookies ...*http.Cookie) (t *Toke
return nil, err return nil, err
} }
json.Unmarshal(b, &m) json.Unmarshal(b, &m)
pp := oclib.Search(nil, string(peer.SELF.EnumIndex()), oclib.LibDataEnum(oclib.PEER)) pp := oclib.Search(nil, strconv.Itoa(peer.SELF.EnumIndex()), oclib.LibDataEnum(oclib.PEER))
if len(pp.Data) == 0 || pp.Code >= 300 || pp.Err != "" { if len(pp.Data) == 0 || pp.Code >= 300 || pp.Err != "" {
return nil, errors.New("peer not found") return nil, errors.New("peer not found")
} }

View File

@ -78,7 +78,7 @@ func (h HydraClaims) DecodeClaimsInToken(host string, method string, forward str
for m, p := range claims { for m, p := range claims {
splittedP := strings.Split(p.(string), "/") splittedP := strings.Split(p.(string), "/")
if len(splittedP) != len(splittedPath) { if len(splittedP) != len(splittedPath) {
return false, errors.New("invalid path") continue
} }
for i, v := range splittedP { for i, v := range splittedP {
if strings.Contains(v, ":") { // is a param if strings.Contains(v, ":") { // is a param