Skip to content

Commit 30a04b7

Browse files
authored
Merge pull request #7 from fisuda/patch-v2
(ja) Update README.ja.md
2 parents 9e819ef + fd2cdf7 commit 30a04b7

1 file changed

Lines changed: 50 additions & 45 deletions

File tree

README.ja.md

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
[![FIWARE Security](https://nexus.lab.fiware.org/repository/raw/public/badges/chapters/security.svg)](https://github.com/FIWARE/catalogue/blob/master/security/README.md)
44
[![License: MIT](https://img.shields.io/github/license/fiware/tutorials.Securing-Access.svg)](https://opensource.org/licenses/MIT)
55
[![Support badge](https://img.shields.io/badge/tag-fiware-orange.svg?logo=stackoverflow)](https://stackoverflow.com/questions/tagged/fiware)
6-
<br/>
7-
[![Documentation](https://img.shields.io/readthedocs/fiware-tutorials.svg)](https://fiware-tutorials.rtfd.io)
6+
<br/> [![Documentation](https://img.shields.io/readthedocs/fiware-tutorials.svg)](https://fiware-tutorials.rtfd.io)
87

98
<!-- prettier-ignore -->
109

@@ -25,7 +24,7 @@ Policy Decision Point (PDP) としても使用されます。
2524

2625
[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/66d8ba3abaf7319941b1)
2726

28-
# コンテンツ
27+
## コンテンツ
2928

3029
<details>
3130
<summary>詳細 <b>(クリックして拡大)</b></summary>
@@ -66,6 +65,7 @@ Policy Decision Point (PDP) としても使用されます。
6665
- [基本認可 (Basic Authorization)](#basic-authorization)
6766
- [基本認可 - サンプル・コード](#basic-authorization---sample-code)
6867
- [PDP アクセス制御 - サンプルの実行](#pdp-access-control---running-the-example)
68+
- [次のステップ](#next-steps)
6969

7070
</details>
7171

@@ -279,27 +279,28 @@ Orion Context Broker と IoT Agent はオープンソースの
279279
## チュートリアルのセキュリティ構成
280280

281281
```yaml
282-
: image: fiware/tutorials.context-provider
283-
hostname: iot-sensors
284-
container_name: fiware-tutorial
285-
networks:
286-
default:
287-
ipv4_address: 172.18.1.7
288-
expose:
289-
- "3000"
290-
- "3001"
291-
ports:
292-
- "3000:3000"
293-
- "3001:3001"
294-
environment:
295-
- "DEBUG=tutorial:*"
296-
- "WEB_APP_PORT=3000"
297-
- "KEYROCK_URL=http://localhost"
298-
- "KEYROCK_IP_ADDRESS=http://172.18.1.5"
299-
- "KEYROCK_PORT=3005"
300-
- "KEYROCK_CLIENT_ID=tutorial-dckr-site-0000-xpresswebapp"
301-
- "KEYROCK_CLIENT_SECRET=tutorial-dckr-site-0000-clientsecret"
302-
- "CALLBACK_URL=http://localhost:3000/login"
282+
tutorial:
283+
image: fiware/tutorials.context-provider
284+
hostname: iot-sensors
285+
container_name: fiware-tutorial
286+
networks:
287+
default:
288+
ipv4_address: 172.18.1.7
289+
expose:
290+
- "3000"
291+
- "3001"
292+
ports:
293+
- "3000:3000"
294+
- "3001:3001"
295+
environment:
296+
- "DEBUG=tutorial:*"
297+
- "WEB_APP_PORT=3000"
298+
- "KEYROCK_URL=http://localhost"
299+
- "KEYROCK_IP_ADDRESS=http://172.18.1.5"
300+
- "KEYROCK_PORT=3005"
301+
- "KEYROCK_CLIENT_ID=tutorial-dckr-site-0000-xpresswebapp"
302+
- "KEYROCK_CLIENT_SECRET=tutorial-dckr-site-0000-clientsecret"
303+
- "CALLBACK_URL=http://localhost:3000/login"
303304
```
304305
305306
`tutorial` コンテナは、2 つのポートでリッスンしています :
@@ -582,25 +583,25 @@ function userCredentialGrant(req, res) {
582583
const password = req.body.password;
583584

584585
oa.getOAuthPasswordCredentials(email, password)
585-
.then(results => {
586+
.then((results) => {
586587
logAccessToken(req, results.access_token);
587588
return getUserFromAccessToken(req, results.access_token);
588589
})
589-
.then(user => {
590+
.then((user) => {
590591
// Store User and return
591592
});
592593
}
593594
```
594595

595596
```javascript
596597
function getUserFromAccessToken(req, accessToken) {
597-
return new Promise(function(resolve, reject) {
598+
return new Promise(function (resolve, reject) {
598599
oa.get(keyrockIPAddress + "/user", accessToken)
599-
.then(response => {
600+
.then((response) => {
600601
const user = JSON.parse(response);
601602
return resolve(user);
602603
})
603-
.catch(error => {
604+
.catch((error) => {
604605
req.flash("error", "User not found");
605606
return reject(error);
606607
});
@@ -666,10 +667,10 @@ function authCodeGrant(req, res) {
666667
function authCodeGrantCallback(req, res) {
667668
return oa
668669
.getOAuthAccessToken(req.query.code)
669-
.then(results => {
670+
.then((results) => {
670671
return getUserFromAccessToken(req, results.access_token);
671672
})
672-
.then(user => {
673+
.then((user) => {
673674
// Store User and return
674675
});
675676
}
@@ -731,7 +732,7 @@ function implicitGrant(req, res) {
731732

732733
```javascript
733734
function implicitGrantCallback(req, res) {
734-
return getUserFromAccessToken(req, req.query.token).then(user => {
735+
return getUserFromAccessToken(req, req.query.token).then((user) => {
735736
// Store User and return
736737
});
737738
}
@@ -812,7 +813,7 @@ curl -iX POST \
812813

813814
```javascript
814815
function clientCredentialGrant(req, res) {
815-
oa.getOAuthClientCredentials().then(results => {
816+
oa.getOAuthClientCredentials().then((results) => {
816817
// Store Access token
817818
});
818819
}
@@ -922,7 +923,7 @@ curl -iX POST \
922923

923924
```javascript
924925
function refreshTokenGrant(req, res) {
925-
return oa.getOAuthRefreshToken(req.session.refresh_token).then(results => {
926+
return oa.getOAuthRefreshToken(req.session.refresh_token).then((results) => {
926927
// Store new Access Token
927928
});
928929
}
@@ -1007,19 +1008,14 @@ function pdpAuthentication(req, res, next) {
10071008
```javascript
10081009
function pdpAuthentication(req, res, next) {
10091010
const keyrockUserUrl =
1010-
keyrockIPAddress +
1011-
"/user" +
1012-
"?access_token=" +
1013-
req.session.access_token +
1014-
"&app_id=" +
1015-
clientId;
1011+
keyrockIPAddress + "/user" + "?access_token=" + req.session.access_token + "&app_id=" + clientId;
10161012
return oa
10171013
.get(keyrockUserUrl)
1018-
.then(response => {
1014+
.then((response) => {
10191015
res.locals.authorized = true;
10201016
return next();
10211017
})
1022-
.catch(error => {
1018+
.catch((error) => {
10231019
debug(error);
10241020
res.locals.authorized = false;
10251021
return next();
@@ -1112,12 +1108,12 @@ function pdpBasicAuthorization(req, res, next, url = req.url) {
11121108
clientId;
11131109
return oa
11141110
.get(keyrockUserUrl)
1115-
.then(response => {
1111+
.then((response) => {
11161112
const user = JSON.parse(response);
11171113
res.locals.authorized = user.authorization_decision === "Permit";
11181114
return next();
11191115
})
1120-
.catch(error => {
1116+
.catch((error) => {
11211117
debug(error);
11221118
res.locals.authorized = false;
11231119
return next();
@@ -1261,8 +1257,17 @@ Charlie には **security** のロールがあります
12611257
- ベルを鳴らします - アクセスが**許可**されます - これは security ユーザに
12621258
許可されます
12631259

1260+
<a name="next-steps"></a>
1261+
1262+
# 次のステップ
1263+
1264+
高度な機能を追加することで、アプリケーションに複雑さを加える方法を知りたいですか
1265+
?このシリーズ
1266+
[他のチュートリアル](https://www.letsfiware.jp/fiware-tutorials)を読むことで見
1267+
つけることができます。
1268+
12641269
---
12651270

12661271
## License
12671272

1268-
[MIT](LICENSE) © 2018-2020 FIWARE Foundation e.V.
1273+
[MIT](LICENSE) © 2018-2022 FIWARE Foundation e.V.

0 commit comments

Comments
 (0)