Skip to content

Commit

Permalink
Improvements to license validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Dec 8, 2018
1 parent 41f5a7f commit be774af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion panel/src/components/Navigation/Topbar.vue
Expand Up @@ -146,7 +146,8 @@ export default {
}
},
unregistered() {
return !this.$store.state.system.info.license ? true : false;
let license = this.$store.state.system.info.license;
return !license || license.substr(0, 3) !== "K3-";
}
},
methods: {
Expand Down
15 changes: 8 additions & 7 deletions src/Cms/System.php
Expand Up @@ -193,26 +193,27 @@ public function license()
}

// check for all required fields for the validation
if (isset($license['order'], $license['date'], $license['email'], $license['signature']) === false) {
if (isset($license['license'], $license['order'], $license['date'], $license['email'], $license['signature']) !== true) {
return false;
}

// build the license verification data
$data = [
'order' => $license['order'],
'email' => hash('sha256', $license['email'] . 'kwAHMLyLPBnHEskzH9pPbJsBxQhKXZnX'),
'date' => $license['date']
'license' => $license['license'],
'order' => $license['order'],
'email' => hash('sha256', $license['email'] . 'kwAHMLyLPBnHEskzH9pPbJsBxQhKXZnX'),
'date' => $license['date']
];

// get the public key
$pubKey = F::read($this->app->root('kirby') . '/kirby.pub');

// verifiy the license signature
// verify the license signature
if (openssl_verify(json_encode($data), hex2bin($license['signature']), $pubKey, 'RSA-SHA256') !== 1) {
return false;
}

return $license['license'] ?? false;
return $license['license'];
}

/**
Expand Down Expand Up @@ -259,7 +260,7 @@ public function register(string $license, string $email): bool
$response = Remote::get('https://licenses.getkirby.com/validate', [
'data' => [
'license' => $license,
'email' => $email
'email' => hash('sha256', $email . 'kwAHMLyLPBnHEskzH9pPbJsBxQhKXZnX')
]
]);

Expand Down

0 comments on commit be774af

Please sign in to comment.