Skip to content

Commit

Permalink
Merge pull request EC-CUBE#29 from onshopVN/feature-sso-ownerstore
Browse files Browse the repository at this point in the history
Implement eccube sso function which allow admin can auto logged into …
  • Loading branch information
ndquocphong authored Sep 24, 2019
2 parents e9de595 + bd4dcb1 commit 84f82a6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
18 changes: 16 additions & 2 deletions app/Customize/Controller/Admin/Store/OwnerStoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,15 @@ public function searchPlugin(Request $request, $page_no = null, Paginator $pagin

$categoriesResult = $this->httpClient->request($endpoint. '/api/v1/plugins/categories', $headers);

$osRegister = $request->attributes->get('osRegister');
$publicKey = base64_decode($osRegister['publicKey']);
$ssoToken = $osRegister['id'] .'|' . $osRegister['email'] . '|' . time();
openssl_public_encrypt($ssoToken, $ssoTokenEncrypted, $publicKey);

return [
'categoriesAsJson' => $categoriesResult,
'installedPluginsAsJson' => json_encode($installedPlugins)
'installedPluginsAsJson' => json_encode($installedPlugins),
'ssoToken' => urlencode(base64_encode($ssoTokenEncrypted))
];
}

Expand Down Expand Up @@ -173,6 +179,8 @@ public function ajaxPlugin(Request $request)
*/
public function searchTemplate()
{
/** @var Request $request */
$request = $this->get('request_stack')->getCurrentRequest();
$endpoint = $this->baseInfo->getOsStoreApiEndpoint();
$headers = [
'Content-Type: application/json',
Expand All @@ -184,9 +192,15 @@ public function searchTemplate()
$installedTemplates[$template->getCode()] = "1.0.0";
}

$osRegister = $request->attributes->get('osRegister');
$publicKey = base64_decode($osRegister['publicKey']);
$ssoToken = $osRegister['id'] .'|' . $osRegister['email'] . '|' . time();
openssl_public_encrypt($ssoToken, $ssoTokenEncrypted, $publicKey);

return [
'categoriesAsJson' => $categoriesResult,
'installedTemplatesDataAsJson' => json_encode($installedTemplates)
'installedTemplatesDataAsJson' => json_encode($installedTemplates),
'ssoToken' => urlencode(base64_encode($ssoTokenEncrypted))
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
loading: false
},
methods: {
prepareUrl: function(url) {
return url + "?sso={{ ssoToken }}"
},
search: function(callback) {
this.submit({pageNum: 1}, callback);
},
Expand Down Expand Up @@ -310,11 +313,11 @@
<div class="col-5">
<div class="plugin-title">
<h5 class="mb-0">
<a class="font-weight-bold" :href="item.url" target="_blank" v-text="item.title"></a>
<a class="font-weight-bold" :href="prepareUrl(item.url)" target="_blank" v-text="item.title"></a>
</h5>
</div>
<div class="plugin-provider mb-3">
by <span><a href="javascript:void(0)" v-text="item.provider"></a></span> in <a :href="item.category.url" target="_blank" v-text="item.category.title"></a>
by <span><a href="javascript:void(0)" v-text="item.provider"></a></span> in <a :href="prepareUrl(item.category.url)" target="_blank" v-text="item.category.title"></a>
</div>
<div class="plugin-version">
<label class="font-weight-bold plugin-attribute">{{ 'customize.store.version'|trans }}:&nbsp;</label>
Expand Down Expand Up @@ -345,7 +348,7 @@
<div class="plugin-download font-italic text-muted"><small><span v-text="item.downloadCount"></span>&nbsp;<span>{{ 'customize.store.download_count'|trans }}</span></small></div>
</div>
<div class="plugin-action position-absolute fixed-bottom px-4 d-flex justify-content-center" style="z-index:1">
<a class="btn btn-ec-regular w-50 mx-1" :href="item.url" target="_blank">{{ 'admin.store.plugin_owners_search.detail'|trans }}</a>
<a class="btn btn-ec-regular w-50 mx-1" :href="prepareUrl(item.url)" target="_blank">{{ 'admin.store.plugin_owners_search.detail'|trans }}</a>

<button class="btn btn-primary w-50 mx-1" :disabled="loading" @click.stop.prevent="install(item)" v-show="item.status === 'install'">
<i class="fa fa-1x fa-arrow-alt-circle-down"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
loading: false,
},
methods: {
prepareUrl: function(url) {
return url + "?sso={{ ssoToken }}"
},
search: function(callback) {
this.submit({pageNum: 1}, callback);
},
Expand Down Expand Up @@ -242,11 +245,11 @@
<div class="col-5">
<div class="plugin-title">
<h5 class="mb-0">
<a class="font-weight-bold" :href="item.url" target="_blank" v-text="item.title"></a>
<a class="font-weight-bold" :href="prepareUrl(item.url)" target="_blank" v-text="item.title"></a>
</h5>
</div>
<div class="plugin-provider mb-3">
by <span><a href="javascript:void(0)" v-text="item.provider"></a></span> in <a :href="item.category.url" target="_blank" v-text="item.category.title"></a>
by <span><a href="javascript:void(0)" v-text="item.provider"></a></span> in <a :href="prepareUrl(item.category.url)" target="_blank" v-text="item.category.title"></a>
</div>
<div class="plugin-version">
<label class="font-weight-bold plugin-attribute">{{ 'customize.store.version'|trans }}:&nbsp;</label>
Expand Down Expand Up @@ -277,7 +280,7 @@
<div class="plugin-download font-italic text-muted"><small><span v-text="item.downloadCount"></span>&nbsp;<span>{{ 'customize.store.download_count'|trans }}</span></small></div>
</div>
<div class="plugin-action position-absolute fixed-bottom px-4 d-flex justify-content-center" style="z-index:1">
<a class="btn btn-ec-regular w-50 mx-1" :href="item.url" target="_blank">{{ 'admin.store.plugin_owners_search.detail'|trans }}</a>
<a class="btn btn-ec-regular w-50 mx-1" :href="prepareUrl(item.url)" target="_blank">{{ 'admin.store.plugin_owners_search.detail'|trans }}</a>
<button class="btn btn-primary w-50 mx-1" :disabled="loading" @click.stop.prevent="install(item)" v-show="item.status === 'install'">
<i class="fa fa-1x fa-arrow-alt-circle-down"></i>
<span class="ladda-label">{{ 'admin.store.plugin_owners_search.install.free'|trans }}</span>
Expand Down

0 comments on commit 84f82a6

Please sign in to comment.