CSteipp has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/159350

Change subject: Add developer agreement
......................................................................

Add developer agreement

At the request of legal, add some an agreement that we can revoke an
app if we need to.

Bug: 62688
Change-Id: I52f94b86730470997327396b6ad53fc5ea7149cf
---
M backend/MWOAuthConsumer.php
M backend/schema/MWOAuthUpdater.hooks.php
A backend/schema/mysql/developer_agreement.sql
M control/MWOAuthConsumerSubmitControl.php
M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
M i18n/en.json
M i18n/qqq.json
7 files changed, 31 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth 
refs/changes/50/159350/1

diff --git a/backend/MWOAuthConsumer.php b/backend/MWOAuthConsumer.php
index ce2fe66..9801727 100644
--- a/backend/MWOAuthConsumer.php
+++ b/backend/MWOAuthConsumer.php
@@ -43,6 +43,8 @@
        protected $email;
        /** @var string TS_MW timestamp of when email address was confirmed */
        protected $emailAuthenticated;
+       /** @var int User accepted the developer agreement */
+       protected $developerAgreement;
        /** @var string Wiki ID the application can be used on (or "*" for all) 
*/
        protected $wiki;
        /** @var string TS_MW timestamp of proposal */
@@ -82,6 +84,7 @@
                                'description'        => 'oarc_description',
                                'email'              => 'oarc_email',
                                'emailAuthenticated' => 
'oarc_email_authenticated',
+                               'developerAgreement' => 
'oarc_developer_agreement',
                                'wiki'               => 'oarc_wiki',
                                'grants'             => 'oarc_grants',
                                'registration'       => 'oarc_registration',
diff --git a/backend/schema/MWOAuthUpdater.hooks.php 
b/backend/schema/MWOAuthUpdater.hooks.php
index e83f674..9ed42bc 100644
--- a/backend/schema/MWOAuthUpdater.hooks.php
+++ b/backend/schema/MWOAuthUpdater.hooks.php
@@ -22,6 +22,14 @@
                        $base = "$base/mysql";
 
                        $updater->addExtensionTable( 
'oauth_registered_consumer', "$base/OAuth.sql" );
+                       $updater->addExtensionUpdate( array(
+                               'addField',
+                               'oauth_registered_consumer',
+                               'oarc_developer_agreement',
+                               "$base/developer_agreement.sql",
+                               true
+                       ) );
+
                } elseif ( $updater->getDB()->getType() == 'postgres' ) {
                        //$base = "$base/postgres";
 
diff --git a/backend/schema/mysql/developer_agreement.sql 
b/backend/schema/mysql/developer_agreement.sql
new file mode 100644
index 0000000..5251a1f
--- /dev/null
+++ b/backend/schema/mysql/developer_agreement.sql
@@ -0,0 +1 @@
+ALTER TABLE /*_*/oauth_registered_consumer ADD COLUMN 
`oarc_developer_agreement` tinyblob NULL DEFAULT NULL AFTER 
`oarc_email_authenticated`;
diff --git a/control/MWOAuthConsumerSubmitControl.php 
b/control/MWOAuthConsumerSubmitControl.php
index 9d1bc22..62d1157 100644
--- a/control/MWOAuthConsumerSubmitControl.php
+++ b/control/MWOAuthConsumerSubmitControl.php
@@ -84,6 +84,9 @@
                                        return is_array( $res ) && 
MWOAuthUtils::restrictionsAreValid( $res );
                                },
                                'rsaKey'       => $validateRsaKey,
+                               'agreement'    => function( $s ) {
+                                       return ( $s == true );
+                               },
                        ),
                        'update'      => array(
                                'consumerKey'  => '/^[0-9a-f]{32}$/',
@@ -182,6 +185,14 @@
                        }
 
                        $now = wfTimestampNow();
+                       $agreeMsg = $this->msg( 
'mwoauth-consumer-developer-agreement' );
+                       $agreeMsgLang = $this->getLanguage()->getCode();
+                       $agreeRegister = implode( ':', array(
+                               $agreeMsg->getKey(),
+                               $agreeMsgLang,
+                               md5( $agreeMsg->inLanguage( $agreeMsgLang 
)->text() )
+                       ) );
+
                        $cmr = MWOAuthConsumer::newFromArray(
                                array(
                                        'id'                 => null, // 
auto-increment
@@ -189,6 +200,7 @@
                                        'userId'             => $centralUserId,
                                        'email'              => 
$user->getEmail(),
                                        'emailAuthenticated' => $now, // see 
above
+                                       'developerAgreement' => $agreeRegister,
                                        'secretKey'          => 
\MWCryptRand::generateHex( 32 ),
                                        'registration'       => $now,
                                        'stage'              => 
MWOAuthConsumer::STAGE_PROPOSED,
diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php 
b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
index d65d286..0eee860 100644
--- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
+++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
@@ -172,6 +172,11 @@
                                                'default' => '',
                                                'rows' => 5
                                        ),
+                                       'agreement' => array(
+                                               'type' => 'check',
+                                               'label-message' => 
'mwoauth-consumer-developer-agreement',
+                                               'required' => true,
+                                       ),
                                        'action' => array(
                                                'type'    => 'hidden',
                                                'default' => 'propose'
diff --git a/i18n/en.json b/i18n/en.json
index 538dabf..c309b5b 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -34,6 +34,7 @@
     "mwoauth-consumer-secretkey": "Consumer secret token:",
     "mwoauth-consumer-accesstoken": "Access token:",
     "mwoauth-consumer-reason": "Reason:",
+    "mwoauth-consumer-developer-agreement": "By submitting this application, 
you acknowledge that we reserve the right to disable your application, remove 
or restrict you or your application's access to this site, and pursue any other 
course of action we deem appropriate if we believe, in our sole judgment, that 
you or your application are violating any policy, guideline, and guiding 
principle of the this site.",
     "mwoauth-consumer-email-unconfirmed": "Your account email address has not 
yet been confirmed.",
     "mwoauth-consumer-email-mismatched": "Provided email address must match 
that of your account.",
     "mwoauth-consumer-alreadyexists": "A consumer with this 
name/version/publisher combination already exists",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index c7bd9e3..d8ba241 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -40,6 +40,7 @@
        "mwoauth-consumer-secretkey": "Used as label for the textarea.",
        "mwoauth-consumer-accesstoken": "Unused at this time.",
        "mwoauth-consumer-reason": "Used as label for the \"Reason\" 
value.\n{{Identical|Reason}}",
+       "mwoauth-consumer-developer-agreement": "Aggreement shown on 
application form, indicating that the app author understands their 
reponsibilities by submitting this form.",
        "mwoauth-consumer-email-unconfirmed": "Used as failure message when 
taking some action which requires email-confirmation.",
        "mwoauth-consumer-email-mismatched": "Used as failure message when 
taking some action.",
        "mwoauth-consumer-alreadyexists": "Used as failure message.",

-- 
To view, visit https://gerrit.wikimedia.org/r/159350
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I52f94b86730470997327396b6ad53fc5ea7149cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: CSteipp <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to