Skip to content

Commit b73b387

Browse files
committed
adding auth warning and update doc
1 parent bed48ba commit b73b387

28 files changed

+326
-198
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,34 @@ AngularJS services to consume [WP-API v2](http://v2.wp-api.org/)
77

88
<http://shprink.github.io/wp-api-angularjs/>
99

10-
## oAuth1
10+
## Authentication
1111

12-
<http://v2.wp-api.org/guide/authentication/>
12+
This library only supports basic auth. OAuth1 not being suitable for JS clients (it would mean exposing key and password out of the open)
1313

14-
### Install OAuth1 plugin
14+
### Basic auth
1515

16-
Export <https://github.com/WP-API/OAuth1> zip and upload it into your WP instance.
16+
Basic auth is only secured to use if used during the app run time and used with a secured connection to your Blog (via SSL).
1717

18-
### Install WP-CLI
18+
#### During run time
19+
20+
Make sure your WP-API runs with an SSL certificate (https) otherwise this will expose your credentials at every request.
21+
22+
Display a form for users to connect and use the following code to register credentials:
1923

2024
```
21-
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
22-
chmod +x wp-cli.phar
23-
sudo mv wp-cli.phar /usr/local/bin/wp
25+
.controller(function(WpApi){
26+
WpApi.setBasicCredentials(<login>, <password>);
27+
});
2428
```
2529

26-
More info: <http://wp-cli.org/>
30+
#### During configuration
2731

28-
### Create a consumer:
32+
You can also set basic credentials during the configuration but use this should only be used for testing as it embed credentials in the application code.
2933

3034
```
31-
$ wp oauth1 add
32-
33-
ID: 4
34-
Key: sDc51JgH2mFu
35-
Secret: LnUdIsyhPFnURkatekRIAUfYV7nmP4iF3AVxkS5PRHPXxgOW
35+
.config(function(WpApiProvider){
36+
WpApiProvider.setBasicCredentials(<login>, <password>);
37+
});
3638
```
3739

3840
## Contribute

config.dist.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
{
22
"baseUrl": "http://sandbox.YourDomain.com/wp-json",
3-
"authType": "basic",
4-
"oauth1": {
5-
"request": "http://sandbox.YourDomain.com/oauth1/request",
6-
"authorize": "http://sandbox.YourDomain.com/oauth1/authorize",
7-
"access": "http://sandbox.YourDomain.com/oauth1/access",
8-
"Key": "yourKey",
9-
"callback": "http://sandbox.YourDomain.com/whatever",
10-
"Secret": "yourSecret"
11-
},
123
"basic": {
13-
"login": "login",
14-
"password": "password"
4+
"login": null,
5+
"password": null
156
},
167
"postsMethods": {
178
"getList": [{

dist/wp-api-angularjs.js

Lines changed: 84 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wp-api-angularjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/docs-setup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ NG_DOCS={
9191
"type": "service",
9292
"moduleName": "wp-api-angularjs",
9393
"shortDescription": "wp-api-angularjs service",
94-
"keywords": "api base function getbaseurl getdefaulthttpproperties http inejct properties public request service url webserver wp-api-angularjs wpapi"
94+
"keywords": "api base basic certificate code connect credentials display expose form function getbaseurl getdefaulthttpproperties http inejct login password properties public register request runs runtime service set setbasiccredentials ssl url users webserver wp-api wp-api-angularjs wpapi"
9595
},
9696
{
9797
"section": "api",
@@ -100,7 +100,7 @@ NG_DOCS={
100100
"type": "service",
101101
"moduleName": "wp-api-angularjs",
102102
"shortDescription": "wp-api-angularjs provider",
103-
"keywords": "api base function newbaseurl provider public service set setbaseurl url webserver webservice wp-api-angularjs wpapiprovider"
103+
"keywords": "addinterceptor allow angularjs api base basic configuration credential credentials defaults definition errors exposes form func function http https input interceptor interceptors lib login modify needed newbaseurl open org overwrite password properties provider public recommended requests response responses return service set setbaseurl setbasiccredentials setdefaulthttpproperties setting-http-headers timeout url user webserver webservice wp-api-angularjs wpapi wpapiprovider"
104104
}
105105
],
106106
"apis": {

0 commit comments

Comments
 (0)