nextcloud / nextcloud/server

Allow to get CookieJar in IClientService

Open
#14,447 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop enhancement good first issue performance 🚀 technical debt
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

With IClientService you can get a wrapped GuzzleClient.
However you have no way to keep the cookies with our API.

The following would work:

		$cookieJar = new \GuzzleHttp\Cookie\CookieJar();

		$client = $this->clientService->newClient();
		$response = $client->post(
			'.../login', [
				'body' => [
					'name' => $name,
					'password' => $password,
				],
				'cookies' => $cookieJar,
			]
		);

		$response = $client->get(
			'.../authed-api', [
				'cookies' => $cookieJar,
			]
		);

I think we should add a newCookieJar() method to the clientService, to hide the Guzzle CookieJar. I just don't know what to do with the interface, Should we add a dummy around it like with the client? and forward all calls to the internal?

cc @MorrisJobke @rullzer agreed and okay for 16?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the IClientService and its clientService implementation, then inspect the existing wrapped Guzzle client and its interface dummy. Determine how a CookieJar can be exposed without leaking the internal client abstraction. Done means callers can create a jar, pass it to successive requests, and retain cookies across those requests with appropriate interface coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.