mirror of
https://github.com/pgsty/minio.git
synced 2026-07-21 21:20:23 +03:00
Bring in the list APIs implemented by Bala <bala@minio.io>
This commit is contained in:
@@ -17,41 +17,45 @@ openssl rsa -in ~/.minio/web/private.key -outform PEM -pubout -out ~/.minio/web/
|
||||
minio server <testdir>
|
||||
```
|
||||
|
||||
### Now you can make curl requests to the server at port 9001.
|
||||
### Implemented JSON RPC APIs.
|
||||
|
||||
Currently username and password are defaulted for testing purposes.
|
||||
Namespace `Web`
|
||||
|
||||
```
|
||||
curl -X POST -H "Content-Type: application/json" -d '{"username":"WLGDGYAQYIGI833EV05A", "password": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"}' http://127.0.0.1:9001/login
|
||||
{"token":"eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NTM1NDM0MjMsImlhdCI6MTQ1MzUwNzQyMywic3ViIjoiV0xHREdZQVFZSUdJODMzRVYwNUEifQ.zhL0vG5dwwak3SvpysW0CzdPRjpadrCLIpte2QHSxj2XjIQb2oK0dDD9Yvl-45E14CMVQhV3CCsf9LFaK2C94I5aop6nP7sSCyG2_l4w2xrfEPWKgyOY9P0QxUIPV3o43o2XjnMlU_6xE2mk8S9N7psk15sf0Ma1EoXkQlfqEZzbxyQjwKx4UxzkVpwN4k6wavtwU-rgVU0QwJwXXss0hVhY7HWtOzUGrhVWL42pOwNwZ73lrHpJkSyQi6fbc5lIALgFoeei_iSUXxRaJjvm36rn4vui3qLCoH79E-WhkoP_mqDvf_YfiTqcFHgdgnu2wtlQl90RNh2-wgR-XJiedQ"}
|
||||
* Login - waits for 'username, password' and on success replies a new JWT token.
|
||||
* ResetToken - resets token, requires password and token.
|
||||
* Logout - currently a dummy operation.
|
||||
* ListBuckets - lists buckets, requires valid token.
|
||||
* ListObjects - lists objects, requires valid token.
|
||||
* GetObjectURL - generates a url for download access, requires valid token.
|
||||
|
||||
### Now you can use `webrpc.js` to make requests.
|
||||
|
||||
- Login example
|
||||
```js
|
||||
var webRPC = require('webrpc');
|
||||
var web = new webRPC("http://localhost:9001/rpc")
|
||||
|
||||
// Generate JWT Token.
|
||||
web.Login({"username": "YOUR-ACCESS-KEY-ID", "password": "YOUR-SECRET-ACCESS-KEY"})
|
||||
.then(function(data) {
|
||||
console.log("success : ", data);
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log("fail : ", error.toString());
|
||||
});
|
||||
```
|
||||
|
||||
Replies back with a token which can be used to logout
|
||||
- ListBuckets example
|
||||
```js
|
||||
var webRPC = require('webrpc');
|
||||
var web = new webRPC("http://localhost:9001/rpc", "my-token")
|
||||
|
||||
```
|
||||
curl -i -X GET -H "Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NTM1NDM0MjMsImlhdCI6MTQ1MzUwNzQyMywic3ViIjoiV0xHREdZQVFZSUdJODMzRVYwNUEifQ.zhL0vG5dwwak3SvpysW0CzdPRjpadrCLIpte2QHSxj2XjIQb2oK0dDD9Yvl-45E14CMVQhV3CCsf9LFaK2C94I5aop6nP7sSCyG2_l4w2xrfEPWKgyOY9P0QxUIPV3o43o2XjnMlU_6xE2mk8S9N7psk15sf0Ma1EoXkQlfqEZzbxyQjwKx4UxzkVpwN4k6wavtwU-rgVU0QwJwXXss0hVhY7HWtOzUGrhVWL42pOwNwZ73lrHpJkSyQi6fbc5lIALgFoeei_iSUXxRaJjvm36rn4vui3qLCoH79E-WhkoP_mqDvf_YfiTqcFHgdgnu2wtlQl90RNh2-wgR-XJiedQ" http://127.0.0.1:9001/logout
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
Date: Sat, 23 Jan 2016 00:05:02 GMT
|
||||
Content-Length: 0
|
||||
```
|
||||
|
||||
|
||||
Now attempt with wrong authorization, you should get 401.
|
||||
|
||||
```
|
||||
$ curl -i -X GET -H "Authorization: Bearer testing123" http://127.0.0.1:9001/logout
|
||||
HTTP/1.1 401 Unauthorized
|
||||
Date: Sat, 23 Jan 2016 00:05:58 GMT
|
||||
Content-Length: 0
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
```
|
||||
|
||||
Without authorization logout is not possible.
|
||||
```
|
||||
$ curl -i -X GET http://127.0.0.1:9001/logout
|
||||
HTTP/1.1 401 Unauthorized
|
||||
Date: Sat, 23 Jan 2016 00:07:00 GMT
|
||||
Content-Length: 0
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
// Generate Token.
|
||||
web.ListBuckets()
|
||||
.then(function(data) {
|
||||
console.log("Success : ", data);
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log("fail : ", error.toString());
|
||||
});
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user