Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCS user endpoint uses wrong data type for booleans #181

Closed
C0rby opened this issue Aug 25, 2020 · 26 comments · Fixed by owncloud/ocis-ocs#39
Closed

OCS user endpoint uses wrong data type for booleans #181

C0rby opened this issue Aug 25, 2020 · 26 comments · Fixed by owncloud/ocis-ocs#39
Labels
bug Something isn't working p2-high

Comments

@C0rby
Copy link

C0rby commented Aug 25, 2020

@jesmrec, tried to connect to https://ocis.owncloud.works using the Android App. The authentication process doesn't finish successfully and upon looking into the backend logs I found this:

2020-08-25T16:26:46Z DBG found account AccountEnabled=true CreatedDateTime=null DeletedDateTime=null Description= DisplayName="Reva Inter Operability Platform" GidNumber=15000 Id=bc596f3c-c955-4328-80a0-60d018b4ad57 Identities=null IsResourceAccount=false Mail=storage@example.org MemberOf=[{"id":"34f38767-c937-4eb6-b847-1c175829a2a0"}] OnPremisesDistinguishedName= OnPremisesLastSyncDateTime=null OnPremisesSamAccountName=reva OnPremisesSecurityIdentifier= OnPremisesSyncEnabled=false OnPremisesUserPrincipalName= PreferredName=reva UidNumber=10001 service=accounts
2020-08-25T16:26:46Z DBG Bind success binddn=cn=reva,ou=sysusers,dc=example,dc=org service=glauth src={"IP":"127.0.0.1","Port":54216,"Zone":""}
2020-08-25 16:26:46.963337 I | handleSearchRequest error LDAP Result Code 1 "Operations Error": LDAP Result Code 201 "": ldap: finished compiling filter with extra at end: (&(objectclass=posixAccount)(|(ownclouduuid=)(cn=)))
2020-08-25T16:26:46Z ERR srv/app/pkg/mod/github.com/cs3org/reva@v1.1.1-0.20200819100654-dcbf0c8ea187/internal/grpc/services/userprovider/userprovider.go:107 > error getting user error="userprovidersvc: error getting user: LDAP Result Code 1 \"Operations Error\": " pkg=rgrpc service=reva traceid=810b3455bb840d82f8ac975745281f54
2020-08-25T16:26:46Z INF unary code=OK end="25/Aug/2020:16:26:46 +0000" from=tcp://127.0.0.1:46362 pkg=rgrpc service=reva start="25/Aug/2020:16:26:46 +0000" time_ns=93856325 traceid=810b3455bb840d82f8ac975745281f54 uri=/cs3.identity.user.v1beta1.UserAPI/GetUser user-agent=grpc-go/1.26.0
{"level":"error","code":"\u000f","time":"2020-08-25T16:26:46.964588479Z","caller":"/srv/app/pkg/mod/github.com/cs3org/reva@v1.1.1-0.20200819100654-dcbf0c8ea187/pkg/storage/fs/owncloud/owncloud.go:542","message":"user lookup failed"}
2020-08-25T16:26:46Z ERR error getting owner error="user lookup failed" pkg=rgrpc service=reva traceid=810b3455bb840d82f8ac975745281f54

Is there a bug in the backend or does the Android App need some changes.

@butonic
Copy link
Member

butonic commented Aug 25, 2020

basic auth or oidc? what user was used? the filter (&(objectclass=posixAccount)(|(ownclouduuid=)(cn=))) looks fishy. grep the log for 810b3455bb840d82f8ac975745281f54 and paste all lines.

@C0rby
Copy link
Author

C0rby commented Aug 25, 2020

It was oidc and einstein.

@C0rby
Copy link
Author

C0rby commented Aug 25, 2020

2020-08-25T16:26:46Z INF access token is already provided pkg=rhttp service=reva traceid=810b3455bb840d82f8ac975745281f54
2020-08-25T16:26:46Z DBG http routing head=remote.php pkg=rhttp service=reva tail=/dav/files traceid=810b3455bb840d82f8ac975745281f54
2020-08-25T16:26:46Z DBG skipping auth method=/cs3.gateway.v1beta1.GatewayAPI/Stat pkg=rgrpc service=reva traceid=810b3455bb840d82f8ac975745281f54
2020-08-25T16:26:46Z INF unary code=OK end="25/Aug/2020:16:26:46 +0000" from=tcp://127.0.0.1:40102 pkg=rgrpc service=reva start="25/Aug/2020:16:26:46 +0000" time_ns=253569 traceid=810b3455bb840d82f8ac975745281f54 uri=/cs3.storage.registry.v1beta1.RegistryAPI/GetStorageProvider user-agent=grpc-go/1.26.0
2020-08-25T16:26:46Z DBG ocfs: unwrap: internal= external=/ pkg=rgrpc service=reva traceid=810b3455bb840d82f8ac975745281f54
2020-08-25T16:26:46Z DBG ocfs: unwrap: internal= external=/ pkg=rgrpc service=reva traceid=810b3455bb840d82f8ac975745281f54
2020-08-25T16:26:46Z DBG skipping auth method=/cs3.identity.user.v1beta1.UserAPI/GetUser pkg=rgrpc service=reva traceid=810b3455bb840d82f8ac975745281f54
2020-08-25T16:26:46Z ERR srv/app/pkg/mod/github.com/cs3org/reva@v1.1.1-0.20200819100654-dcbf0c8ea187/internal/grpc/services/userprovider/userprovider.go:107 > error getting user error="userprovidersvc: error getting user: LDAP Result Code 1 \"Operations Error\": " pkg=rgrpc service=reva traceid=810b3455bb840d82f8ac975745281f54
2020-08-25T16:26:46Z INF unary code=OK end="25/Aug/2020:16:26:46 +0000" from=tcp://127.0.0.1:46362 pkg=rgrpc service=reva start="25/Aug/2020:16:26:46 +0000" time_ns=93856325 traceid=810b3455bb840d82f8ac975745281f54 uri=/cs3.identity.user.v1beta1.UserAPI/GetUser user-agent=grpc-go/1.26.0
2020-08-25T16:26:46Z ERR error getting owner error="user lookup failed" pkg=rgrpc service=reva traceid=810b3455bb840d82f8ac975745281f54
2020-08-25T16:26:46Z INF unary code=OK end="25/Aug/2020:16:26:46 +0000" from=tcp://127.0.0.1:52412 pkg=rgrpc service=reva start="25/Aug/2020:16:26:46 +0000" time_ns=97244681 traceid=810b3455bb840d82f8ac975745281f54 uri=/cs3.storage.provider.v1beta1.ProviderAPI/Stat user-agent=grpc-go/1.26.0
2020-08-25T16:26:46Z INF unary code=OK end="25/Aug/2020:16:26:46 +0000" from=tcp://127.0.0.1:40166 pkg=rgrpc service=reva start="25/Aug/2020:16:26:46 +0000" time_ns=100144974 traceid=810b3455bb840d82f8ac975745281f54 uri=/cs3.gateway.v1beta1.GatewayAPI/Stat user-agent=grpc-go/1.26.0
2020-08-25T16:26:46Z INF http end="25/Aug/2020:16:26:46 +0000" host=127.0.0.1 method=PROPFIND pkg=rhttp proto=HTTP/1.1 service=reva size=1018 start="25/Aug/2020:16:26:46 +0000" status=207 time_ns=103004182 traceid=810b3455bb840d82f8ac975745281f54 uri=/remote.php/dav/files/ url=/remote.php/dav/files/

@C0rby
Copy link
Author

C0rby commented Aug 25, 2020

Some more info from Jesus.

There is no 4xx/5xx response. Both finish execution after requesting ocs/v2.php/cloud/user?format=json endpoint which response is more populated as in oC10 (f ex, contains quota information). iOS app shows as error Response was in unknown format (error 16).

@jesmrec
Copy link

jesmrec commented Aug 25, 2020

Differences:

  1. Container built some days ago (ocis version 2c4727d)

GET https://xxxx:9200/ocs/v2.php/cloud/user?format=json -> 200
Raw:
{"ocs":{"meta":{"status":"ok","statuscode":200,"message":"OK"},"data":{"id":"einstein","display-name":"Einstein","email":"einstein@example.org"}}}

  1. Current ocis.owncloud.works

GET https://ocis.owncloud.works/ocs/v2.php/cloud/user?format=json -> 200

Json:

    "data": {
        "displayname": "Albert Einstein",
        "email": "einstein@example.org",
        "enabled": true,
        "gidnumber": 30000,
        "id": "4c510ada-c86b-4815-8820-42cdf82c3d51",
        "quota": {
            "definition": "default",
            "free": 2840756224000,
            "relative": 0.18,
            "total": 2845815640668,
            "used": 5059416668
        },
        "uidnumber": 20000,
        "username": "einstein"
    },
    "meta": {
        "message": "OK",
        "status": "ok",
        "statuscode": 200
    }
}```

@jesmrec
Copy link

jesmrec commented Aug 25, 2020

I will add authorization info, just in case is useful as well

@butonic
Copy link
Member

butonic commented Aug 25, 2020

the output from ocis should now match the one from oc10:

curl https://ocis.owncloud.works/ocs/v1.php/cloud/users/4c510ada-c86b-4815-8820-42cdf82c3d51\?format\=json -u einstein | jq
{
  "meta": {
    "status": "ok",
    "statuscode": 100,
    "message": "OK"
  },
  "data": {
    "enabled": true,
    "id": "4c510ada-c86b-4815-8820-42cdf82c3d51",
    "username": "einstein",
    "displayname": "Albert Einstein",
    "email": "einstein@example.org",
    "quota": {
      "free": 2840756224000,
      "used": 5059416668,
      "total": 2845815640668,
      "relative": 0.18,
      "definition": "default"
    },
    "uidnumber": 20000,
    "gidnumber": 30000
  }
}

vs

curl https://demo.owncloud.com/ocs/v1.php/cloud/users/admin\?format\=json -u admin | jq
{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 100,
      "message": null
    },
    "data": {
      "enabled": "true",
      "quota": {
        "free": 25404542976,
        "used": 6784009,
        "total": 25411326985,
        "relative": 0.03,
        "definition": "default"
      },
      "email": null,
      "displayname": "admin",
      "home": "/var/lib/owncloud/files/admin",
      "two_factor_auth_enabled": "false"
    }
  }
}

yes uidnumber, gidnumber, id and username are new, but TCP is built on the robustness principle and it applies here as well. This is only additional data.

hmm

the "enabled" now is a bool instead of a string ... that might indeed kill the current parser that is tailored to parse the json ocs produces...

hm in reva we have an ocsBool:

type ocsBool bool

func (c *ocsBool) MarshalJSON() ([]byte, error) {
	if *c {
		return []byte("true"), nil
	}

	return []byte("false"), nil
}

func (c ocsBool) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if c {
		return e.EncodeElement("1", start)
	}

	return e.EncodeElement("0", start)
}

let me check ocis-ocs which now implements the endpoint.

owncloud/ocis-ocs#39 now uses the truthy rendering, which should now return boolean true and false not strings in json and 0 and 1 in xml ... but I find it weird that oc10 returns a string for enabled ...

@butonic
Copy link
Member

butonic commented Aug 25, 2020

@jesmrec jesmrec changed the title Authentication via the Android app fails Authentication via the mobile apps fails Aug 26, 2020
@PVince81 PVince81 changed the title Authentication via the mobile apps fails OCS user endpoint uses wrong data type for booleans Aug 26, 2020
@PVince81 PVince81 transferred this issue from owncloud/ocis Aug 26, 2020
@exalate-issue-sync
Copy link

exalate-issue-sync bot commented Aug 26, 2020

Vincent Petry commented: Set to p2

This is blocking testing efforts about TUS for mobile.

It can wait until the next sprint but would be good to have it early in the next sprint.

@butonic
Copy link
Member

butonic commented Aug 28, 2020

ocis.owncloud.works now returns this:

{
  "meta": {
    "status": "ok",
    "statuscode": 100,
    "message": "OK"
  },
  "data": {
    "enabled": "true",
    "id": "4c510ada-c86b-4815-8820-42cdf82c3d51",
    "username": "einstein",
    "displayname": "Albert Einstein",
    "email": "einstein@example.org",
    "quota": {
      "free": 2840756224000,
      "used": 5059416668,
      "total": 2845815640668,
      "relative": 0.18,
      "definition": "default"
    },
    "uidnumber": 20000,
    "gidnumber": 30000
  }
}

@jesmrec
Copy link

jesmrec commented Aug 31, 2020

Unfortunately, clients still fail with this response. Checking out what's going on...

@jesmrec jesmrec reopened this Aug 31, 2020
@jesmrec
Copy link

jesmrec commented Aug 31, 2020

would it have to do that:

Before: { ocs { meta {...}, {data {...}}
Now: {meta {...}, {data {...}} -> ocs node is missing/removed.

??

checking...

@butonic @PVince81

@jesmrec
Copy link

jesmrec commented Sep 2, 2020

owncloud/ocis-ocs#47 did not fix. This is because another difference is there:

Before: display-name
Now: displayname

That makes Android not to finish the log on process and iOS finishes but display name is missing everywhere in the app

@C0rby
Copy link
Author

C0rby commented Sep 2, 2020

I just noticed that the responses from /cloud/users/admin and /cloud/user differ....

curl https://demo.owncloud.com/ocs/v1.php/cloud/users/admin\?format\=json -u admin -s | jq
{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 100,
      "message": null
    },
    "data": {
      "enabled": "true",
      "quota": {
        "free": 25287991296,
        "used": 6784009,
        "total": 25294775305,
        "relative": 0.03,
        "definition": "default"
      },
      "email": null,
      "displayname": "admin",
      "home": "/var/lib/owncloud/files/admin",
      "two_factor_auth_enabled": "false"
    }
  }
}

displayname

curl https://demo.owncloud.com/ocs/v1.php/cloud/user\?format\=json -u admin -s | jq
{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 100,
      "message": "OK",
      "totalitems": "",
      "itemsperpage": ""
    },
    "data": {
      "id": "admin",
      "display-name": "admin",
      "email": null
    }
  }
}

display-name

This is awful... 😞

@TheOneRing
Copy link
Member

TheOneRing commented Sep 7, 2020

Is displayname display-name the only issue that requires client changes?
We need to coordinate changes like this with all clients.

owncloud/client#8044

@jesmrec
Copy link

jesmrec commented Sep 7, 2020

Should this be changed in clients? this is not very backwards compatible then...

@TheOneRing
Copy link
Member

According to @butonic we should support both

TheOneRing pushed a commit to owncloud/client that referenced this issue Sep 8, 2020
TheOneRing pushed a commit to owncloud/client that referenced this issue Sep 8, 2020
@michaelstingl
Copy link

michaelstingl commented Sep 9, 2020

Should this be changed in clients? this is not very backwards compatible then...

Just checked with @felixboehm and @micbar , different attribute names ("displayname" vs "display-name") is a bug and needs to be fixed in the backed. @TheOneRing you could revert the client change…

@TheOneRing
Copy link
Member

So the server will not change the naming? and keep different spellings?

@michaelstingl
Copy link

So the server will not change the naming? and keep different spellings?

Backend needs to be fixed. Spelling will be same as oC 10. (ocs is legacy API and deprecated, so no need to introduce new structures…)

@michaelstingl
Copy link

michaelstingl commented Sep 15, 2020

I was checking with oC10 Docker, new iOS, current Android, and 2.7 desktop, they all use the same user endpoint:

GET /ocs/v2.php/cloud/user?format=json HTTP/1.1" 200 1266 "-" "ownCloudApp/11.4 (App/169; iOS/13.7; iPhone)
GET /ocs/v1.php/cloud/user?format=json HTTP/1.1" 200 854 "-" "Mozilla/5.0 (Macintosh) mirall/2.7.0 (build 2111) (ownCloud, osx-19.6.0 ClientArchitecture: x86_64 OsArchitecture: x86_64)
GET /ocs/v2.php/cloud/user?format=json HTTP/1.1" 200 854 "-" "Mozilla/5.0 (Android) ownCloud-android/2.15.2
% curl -u "admin:admin" "http://192.168.2.136:18080/ocs/v2.php/cloud/user?format=json" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   156  100   156    0     0   1695      0 --:--:-- --:--:-- --:--:--  1695
{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 200,
      "message": "OK",
      "totalitems": "",
      "itemsperpage": ""
    },
    "data": {
      "id": "admin",
      "display-name": "admin",
      "email": null
    }
  }
}

@michaelstingl
Copy link

iOS app and 2.7 desktop try the same with GET https://ocis.owncloud.works/ocs/v2.php/cloud/user?format=json

{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 200,
      "message": "OK"
    },
    "data": {
      "enabled": "true",
      "id": "4c510ada-c86b-4815-8820-42cdf82c3d51",
      "username": "einstein",
      "displayname": "Albert Einstein",
      "email": "einstein@example.org",
      "quota": {
        "free": 2840756224000,
        "used": 5059416668,
        "total": 2845815640668,
        "relative": 0.18,
        "definition": "default"
      },
      "uidnumber": 20000,
      "gidnumber": 30000
    }
  }
}
IMG_9B4BD5DB6C3B-1 CleanShot 2020-09-15 at 22 29 04@2x>
iOS 11.4 shows 4c510ada-c86b-4815-8820-42cdf82c3d51 Desktop 2.7 shows 4c510ada-c86b-4815-8820-42cdf82c3d51

@michaelstingl
Copy link

michaelstingl commented Sep 15, 2020

From client perspective, only /ocs/v2.php/cloud/user is sufficient, and it MUST contain display-name!!

@C0rby
Copy link
Author

C0rby commented Sep 17, 2020

Connecting via the Android App works now.

@C0rby C0rby closed this as completed Sep 17, 2020
@exalate-issue-sync exalate-issue-sync bot reopened this Oct 21, 2020
@exalate-issue-sync exalate-issue-sync bot added the bug Something isn't working label Oct 21, 2020
@exalate-issue-sync
Copy link

Vincent Petry commented: Mobile team might have a workaround, but it might not be worth working around if fixing the issue is trivial.

[~dchristofas] are you able to quickly estimate the effort ? My gut feeling tells me that it might be a one liner.

cc [~mbarz]

@exalate-issue-sync
Copy link

Jörn Friedrich Dreyer commented: I'll work on this while waiting for builds to finish ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2-high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants