Skip to content

Commit

Permalink
V6/refactor/auth module (#1986)
Browse files Browse the repository at this point in the history
* Add authentication database migrations

* Add token-generation script

* Rename permission table to role_ability

* Make token id a string

* Add jwt-util

* Split jwt decoding and getPayload functions

* Decouple test from jsonwebtoken lib

* Update doc

* Add test for expired jwt validation

* Implement isAuthenticated method

* Implement isAuthorized method

* Implement abilities fetching

* Implement isActionPublic method

* rename isPublicAction method to isActionPublic

* Implement auth middlewares

* Update config structure

* Fix isRevoked promise bug

* Fix token-generation script

* Integrate auth middlewares

* Fix repository to accept tokenId param

* Remove unused middleware

* Move middlewares to separate folder

* Fix method logic to fit method name

* Add tests for middlewares

* Update config.json

* Use publicOperation instead of publicAction

* Merge _isRevoked method inside of _isTokenValid method

* Fix typo

* Fix model association bug

* Add logging for auth-service

* Fix bug when token is valid but not recorded in the database

* Update config.json with loggingEnabled field

* Enable pre-commit git hook
  • Loading branch information
vterzic authored Aug 9, 2022
1 parent 52d98b8 commit 864f77a
Show file tree
Hide file tree
Showing 32 changed files with 2,107 additions and 46 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ module.exports = {
'no-continue': 1,
'no-underscore-dangle': 0,
},
"overrides": [
{
"files": ["*.test.js", "*.spec.js"],
"rules": {
"no-unused-expressions": "off"
}
}
]
};
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

#npm run lint-staged
npm run lint-staged
44 changes: 40 additions & 4 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,23 @@
"port": 9000,
"bootstrap": []
},
"ipWhitelist": ["::1", "127.0.0.1"],
"telemetryHub": {
"enabled": false,
"packages": ["ot-telemetry-collector"],
"url": ""
},
"operationalDatabase": {
"databaseName": "operationaldb"
},
"auth": {
"ipBasedAuthEnabled": true,
"tokenBasedAuthEnabled": false,
"loggingEnabled": true,
"ipWhitelist": [
"::1",
"127.0.0.1"
],
"publicOperations": []
}
},
"test": {
Expand Down Expand Up @@ -267,14 +276,23 @@
"port": 9000,
"bootstrap": []
},
"ipWhitelist": ["::1", "127.0.0.1"],
"telemetryHub": {
"enabled": false,
"packages": ["ot-telemetry-collector"],
"url": ""
},
"operationalDatabase": {
"databaseName": "operationaldb"
},
"auth": {
"ipBasedAuthEnabled": true,
"tokenBasedAuthEnabled": false,
"loggingEnabled": true,
"ipWhitelist": [
"::1",
"127.0.0.1"
],
"publicOperations": []
}
},
"testnet": {
Expand Down Expand Up @@ -432,14 +450,23 @@
"/ip4/46.101.153.21/tcp/9000/p2p/QmXzmTqVT3TPUtTz4dBDN5NWSABqnX9rKXCG9WCLXMfEaM"
]
},
"ipWhitelist": ["::1", "127.0.0.1"],
"telemetryHub": {
"enabled": true,
"packages": ["ot-telemetry-collector"],
"url": "https://polaris.delta.origin-trail.network/metrics/"
},
"operationalDatabase": {
"databaseName": "operationaldb"
},
"auth": {
"ipBasedAuthEnabled": true,
"tokenBasedAuthEnabled": false,
"loggingEnabled": true,
"ipWhitelist": [
"::1",
"127.0.0.1"
],
"publicOperations": []
}
},
"mainnet": {
Expand Down Expand Up @@ -552,14 +579,23 @@
"port": 9000,
"bootstrap": []
},
"ipWhitelist": ["::1", "127.0.0.1"],
"telemetryHub": {
"enabled": false,
"packages": ["ot-telemetry-collector"],
"url": ""
},
"operationalDatabase": {
"databaseName": "operationaldb"
},
"auth": {
"ipBasedAuthEnabled": true,
"tokenBasedAuthEnabled": false,
"loggingEnabled": true,
"ipWhitelist": [
"::1",
"127.0.0.1"
],
"publicOperations": []
}
}
}
Loading

0 comments on commit 864f77a

Please sign in to comment.