This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Refs #0963. Moved userapi and token models to core; moved authen…
…tication component to core.
- Loading branch information
Showing
46 changed files
with
265 additions
and
435 deletions.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
/** | ||
* Upgrade 3.2.13 move userapi and token to core | ||
*/ | ||
class Upgrade_3_2_13 extends MIDASUpgrade | ||
{ | ||
|
||
public function preUpgrade() | ||
{ | ||
|
||
} | ||
|
||
public function mysql() | ||
{ | ||
$this->db->query("CREATE TABLE IF NOT EXISTS `api_userapi` ( | ||
`userapi_id` bigint(20) NOT NULL AUTO_INCREMENT, | ||
`user_id` bigint(20) NOT NULL, | ||
`apikey` varchar(40) NOT NULL, | ||
`application_name` varchar(256) NOT NULL, | ||
`token_expiration_time` int(11) NOT NULL, | ||
`creation_date` timestamp NULL DEFAULT NULL, | ||
PRIMARY KEY (`userapi_id`) | ||
)"); | ||
$this->db->query("RENAME TABLE `api_userapi` to `userapi`"); | ||
|
||
$this->db->query("CREATE TABLE IF NOT EXISTS `api_token` ( | ||
`token_id` bigint(20) NOT NULL AUTO_INCREMENT, | ||
`userapi_id` bigint(20) NOT NULL, | ||
`token` varchar(40) NOT NULL, | ||
`expiration_date` timestamp NULL DEFAULT NULL, | ||
PRIMARY KEY (`token_id`) | ||
)"); | ||
$this->db->query("RENAME TABLE `api_token` to `token`"); | ||
} | ||
|
||
public function pgsql() | ||
{ | ||
$this->db->query("CREATE TABLE api_userapi ( | ||
userapi_id serial PRIMARY KEY, | ||
user_id bigint NOT NULL, | ||
apikey character varying(40) NOT NULL, | ||
application_name character varying(256) NOT NULL, | ||
token_expiration_time integer NOT NULL, | ||
creation_date timestamp without time zone | ||
)"); | ||
$this->db->query("ALTER TABLE api_userapi_userapi_id_seq RENAME TO userapi_userapi_id_seq"); | ||
$this->db->query("ALTER TABLE api_userapi RENAME TO userapi"); | ||
$this->db->query("ALTER INDEX api_userapi_pkey RENAME TO userapi_pkey"); | ||
|
||
$this->db->query("CREATE TABLE api_token ( | ||
token_id serial PRIMARY KEY, | ||
userapi_id bigint NOT NULL, | ||
token character varying(40) NOT NULL, | ||
expiration_date timestamp without time zone | ||
)"); | ||
$this->db->query("ALTER TABLE api_token_token_id_seq RENAME TO token_token_id_seq"); | ||
$this->db->query("ALTER TABLE api_token RENAME TO token"); | ||
$this->db->query("ALTER INDEX api_token_pkey RENAME TO token_pkey"); | ||
} | ||
|
||
public function postUpgrade() | ||
{ | ||
$userModel = MidasLoader::loadModel('User'); | ||
$userapiModel = MidasLoader::loadModel('Userapi'); | ||
|
||
//limit this to 100 users; there shouldn't be very many when api is installed | ||
$users = $userModel->getAll(false, 100, 'admin'); | ||
foreach($users as $user) | ||
{ | ||
$userApiDao = $userapiModel->getByAppAndEmail('Default', $user->getEmail()); | ||
if($userApiDao != false) | ||
{ | ||
$userDefaultApiKey = $userApiDao->getApikey(); | ||
if(!empty($userDefaultApiKey)) | ||
{ | ||
continue; | ||
} | ||
} | ||
$userapiModel->createDefaultApiKey($user); | ||
} | ||
} | ||
|
||
} | ||
?> |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<dataset> | ||
|
||
<token token_id="1000" userapi_id="1000" token="cleanTable" expiration_date="2011-01-27 12:09:02" /> | ||
<userapi userapi_id="1000" user_id="1000" apikey="cleanTable" application_name="cleanTable" | ||
token_expiration_time="100" creation_date="2011-01-27 12:09:02" /> | ||
|
||
</dataset> | ||
|
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
Oops, something went wrong.