Skip to content

Commit 5e2ac7d

Browse files
committed
first commit
1 parent b2b479e commit 5e2ac7d

18 files changed

+863
-1
lines changed

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: laravel

README.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,56 @@
1-
# laravel-google-recaptcha-v3
1+
# GoogleReCaptcha
2+
3+
[![Latest Version on Packagist][ico-version]][link-packagist]
4+
[![Total Downloads][ico-downloads]][link-downloads]
5+
[![Build Status][ico-travis]][link-travis]
6+
[![StyleCI][ico-styleci]][link-styleci]
7+
8+
This is where your description should go. Take a look at [contributing.md](contributing.md) to see a to do list.
9+
10+
## Installation
11+
12+
Via Composer
13+
14+
``` bash
15+
$ composer require ryandeng/googlerecaptcha
16+
```
17+
18+
## Usage
19+
20+
## Change log
21+
22+
Please see the [changelog](changelog.md) for more information on what has changed recently.
23+
24+
## Testing
25+
26+
``` bash
27+
$ composer test
28+
```
29+
30+
## Contributing
31+
32+
Please see [contributing.md](contributing.md) for details and a todolist.
33+
34+
## Security
35+
36+
If you discover any security related issues, please email ryandadeng@gmail.com instead of using the issue tracker.
37+
38+
## Credits
39+
40+
- [Ryan Deng][link-author]
41+
- [All Contributors][link-contributors]
42+
43+
## License
44+
45+
MIT. Please see the [license file](license.md) for more information.
46+
47+
[ico-version]: https://img.shields.io/packagist/v/ryandeng/googlerecaptcha.svg?style=flat-square
48+
[ico-downloads]: https://img.shields.io/packagist/dt/ryandeng/googlerecaptcha.svg?style=flat-square
49+
[ico-travis]: https://img.shields.io/travis/ryandeng/googlerecaptcha/master.svg?style=flat-square
50+
[ico-styleci]: https://styleci.io/repos/12345678/shield
51+
52+
[link-packagist]: https://packagist.org/packages/ryandeng/googlerecaptcha
53+
[link-downloads]: https://packagist.org/packages/ryandeng/googlerecaptcha
54+
[link-travis]: https://travis-ci.org/ryandeng/googlerecaptcha
55+
[link-styleci]: https://styleci.io/repos/12345678
56+
[link-author]: https://github.com/ryandadeng

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
All notable changes to `GoogleReCaptcha` will be documented in this file.
4+
5+
## Version 1.0
6+
7+
### Added
8+
- Everything

composer.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "ryandeng/googlerecaptcha",
3+
"description": "Laravel 5.x library for reCAPTCHA v3",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Ryan Deng",
8+
"email": "ryandadeng@gmail.com",
9+
"homepage": "https://ryandeng.com"
10+
}
11+
],
12+
"homepage": "https://github.com/RyanDaDeng/laravel-google-recaptcha-v3",
13+
"keywords": [
14+
"Laravel",
15+
"GoogleReCaptcha",
16+
"reCAPTCHA v3",
17+
"Laravel reCAPTCHA"
18+
],
19+
"require": {
20+
"php": ">=5.5",
21+
"illuminate/support": "~5"
22+
},
23+
"require-dev": {
24+
"phpunit/phpunit": "~7.0",
25+
"mockery/mockery": "^1.1",
26+
"orchestra/testbench": "~3.0",
27+
"sempro/phpunit-pretty-print": "^1.0"
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"RyanDeng\\GoogleReCaptcha\\": "src/"
32+
}
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"RyanDeng\\GoogleReCaptcha\\Tests\\": "tests"
37+
}
38+
},
39+
"extra": {
40+
"laravel": {
41+
"providers": [
42+
"RyanDeng\\GoogleReCaptcha\\Providers\\GoogleReCaptchaServiceProvider"
43+
],
44+
"aliases": {
45+
"GoogleReCaptcha": "RyanDeng\\GoogleReCaptcha\\Facades\\GoogleReCaptcha"
46+
}
47+
}
48+
}
49+
}

config/googlerecaptcha.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
return [
4+
'is_service_enabled' => true,
5+
'host_name' => 'ryandeng.test',
6+
'secret_key' => '6Lez2HcUAAAAAIvmnukbhNLUAighVP6AuPcOFXT2',
7+
'curl_timeout' => 1,
8+
'curl_verify' => false,
9+
'template' => 'GoogleReCaptcha::googlerecaptcha.googlerecaptcha',
10+
'site_key' => '6Lez2HcUAAAAAJPDe-qVi5H8G5FB049E5mrljqt4',
11+
'options' => [
12+
'curl_timeout' => 1,
13+
'curl_verify' => 1,
14+
],
15+
'is_score_enabled' => true,
16+
'score_setting' => [
17+
[
18+
'action' => 'a',
19+
'id' => 'cccc',
20+
'threshold' => 0.2,
21+
'is_enabled' => false
22+
],
23+
[
24+
'action' => 'c',
25+
'id' => 'ddd',
26+
'threshold' => 0.1,
27+
'is_enabled' => true
28+
],
29+
],
30+
'site_verify_url' => 'https://www.google.com/recaptcha/api/siteverify',
31+
];

contributing.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contributing
2+
3+
Contributions are welcome and will be fully credited.
4+
5+
Contributions are accepted via Pull Requests on [Github](https://github.com/ryandeng/googlerecaptcha).
6+
7+
# Things you could do
8+
If you want to contribute but do not know where to start, this list provides some starting points.
9+
- Add license text
10+
- Remove rewriteRules.php
11+
- Set up TravisCI, StyleCI, ScrutinizerCI
12+
- Write a comprehensive ReadMe
13+
14+
## Pull Requests
15+
16+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
17+
18+
- **Document any change in behaviour** - Make sure the `readme.md` and any other relevant documentation are kept up-to-date.
19+
20+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
21+
22+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
23+
24+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
25+
26+
27+
**Happy coding**!

license.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# The license
2+
3+
Copyright (c) Ryan Deng <ryandadeng@gmail.com>

phpunit.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
verbose="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false">
12+
<testsuites>
13+
<testsuite name="Package">
14+
<directory suffix=".php">./tests/</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory>src/</directory>
20+
</whitelist>
21+
</filter>
22+
</phpunit>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script src="https://www.google.com/recaptcha/api.js?render={{$publicKey}}"></script>
2+
<script>
3+
grecaptcha.ready(function () {
4+
@foreach($rows as $action =>$id)
5+
grecaptcha.execute('{{$publicKey}}', {action: '{{$action}}'}).then(function (token) {
6+
document.getElementById('{{$id}}').value = token;
7+
});
8+
@endforeach
9+
});
10+
</script>
11+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
namespace RyanDeng\GoogleReCaptcha\Configurations;
4+
5+
6+
use RyanDeng\GoogleReCaptcha\Interfaces\ReCaptchaConfigInterface;
7+
8+
class ReCaptchaConfig implements ReCaptchaConfigInterface
9+
{
10+
public function isServiceEnabled()
11+
{
12+
return config('googlerecaptcha.site_key');
13+
}
14+
15+
public function getSiteVerifyUrl()
16+
{
17+
return config('googlerecaptcha.site_verify_url');
18+
}
19+
20+
public function getHostName()
21+
{
22+
return config('googlerecaptcha.host_name');
23+
}
24+
25+
public function isScoreEnabled()
26+
{
27+
return config('googlerecaptcha.is_score_enabled');
28+
}
29+
30+
/**
31+
* @return string
32+
*/
33+
public function getSecretKey()
34+
{
35+
return config('googlerecaptcha.secret_key');
36+
}
37+
38+
/**
39+
* @return int
40+
*/
41+
public function getCurlTimeout()
42+
{
43+
return config('googlerecaptcha.options.curl_timeout');
44+
}
45+
46+
/**
47+
* @return bool
48+
*/
49+
public function getCurlVerify()
50+
{
51+
return config('googlerecaptcha.options.curl_verify');
52+
}
53+
54+
/**
55+
* @return string
56+
*/
57+
public function getTemplate()
58+
{
59+
return config('googlerecaptcha.template');
60+
}
61+
62+
/**
63+
* @return string
64+
*/
65+
public function getSiteKey()
66+
{
67+
return config('googlerecaptcha.site_key');
68+
}
69+
70+
71+
/**
72+
* @return array
73+
*/
74+
public function getOptions()
75+
{
76+
77+
return config('googlerecaptcha.options');
78+
}
79+
80+
81+
/**
82+
* @return array
83+
*/
84+
public function getScoreSetting()
85+
{
86+
return config('googlerecaptcha.score_setting');
87+
}
88+
}

0 commit comments

Comments
 (0)