-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add default client ids for desktop and mobile clients #38
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
namespace OCA\oauth2\Migrations; | ||
|
||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException; | ||
use OCA\OAuth2\Db\Client; | ||
use OCA\OAuth2\Db\ClientMapper; | ||
use OCP\Migration\ISimpleMigration; | ||
use OCP\Migration\IOutput; | ||
|
||
/** | ||
* This adds the default client ids for ownCloud mobile and desktop clients | ||
*/ | ||
class Version20170329194544 implements ISimpleMigration { | ||
|
||
private static $registry = [ | ||
['Desktop Client', 'http://localhost:*', 'xdXOt13JKxym1B1QcEncf2XDkLAexMBFwiT9j6EfhhHFJhs2KM9jbjTmf8JBXE69', 'UBntmLjC2yYCeHwsyj73Uwo9TAaecAetRwMw0xYcvNL9yRdLSUi0hUAHfvCHFeFh'], | ||
['Android', 'oc://android.owncloud.com', 'e4rAsNUSIUs0lF4nbv9FmCeUkTlV9GdgTLDH1b5uie7syb90SzEVrbN7HIpmWJeD', 'dInFYGV33xKzhbRmpqQltYNdfLdJIfJ9L5ISoKhNoT9qZftpdWSP71VrpGR9pmoD'], | ||
// ['iOS', '???', 'mxd5OQDk6es5LzOzRvidJNfXLUZS2oN3oUFeXPP8LpPrhx3UroJFduGEYIBOxkY1', 'KFeFWWEZO9TkisIQzR3fo7hfiMXlOpaqP8CFuTbSHzV1TUuGECglPxpiVKJfOXIx'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use oc://ios.owncloud.com as callback URL for the iOS client? The old iOS code is not testable right now, but the URI should work anyway. |
||
]; | ||
/** | ||
* @param IOutput $out | ||
*/ | ||
public function run(IOutput $out) { | ||
foreach(self::$registry as list($name, $redirectUrl, $clientId, $secret)) { | ||
try { | ||
$this->addClient($name, $redirectUrl, $clientId, $secret); | ||
|
||
$out->info("The client <$name> has been added."); | ||
} catch (UniqueConstraintViolationException $ex) { | ||
$out->info("The client <$name> already known."); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @param string $redirectUrl | ||
* @param string $clientId | ||
* @param string $secret | ||
*/ | ||
protected function addClient($name, $redirectUrl, $clientId, $secret) { | ||
/** @var ClientMapper $mapper */ | ||
$mapper = \OC::$server->query(ClientMapper::class); | ||
|
||
$client = new Client(); | ||
$client->setIdentifier($clientId); | ||
$client->setSecret($secret); | ||
$client->setRedirectUri($redirectUrl); | ||
$client->setName($name); | ||
$client->setAllowSubdomains(false); | ||
|
||
$mapper->insert($client); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oc:// is actually a very short name. It it not true that these need to be globally registered on the whole phone?
Would it not be better to have something longer such as owncloud:// or even owncloudauth:// ?
Also, can two different owncloud client co-exist on the same phone? (say, a branded client, the original owncloud client, and the nextcloud client)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points, but only relevant for the current POC in Android. For the final implementation we will not register the callback globally and will not use an external web browser. Everything will happen in a WebView owned by the app, and only it will monitor the URLs loaded.
I like owncloud:// , that's what we used originally; oc:// was just more handy :)