@travetto/auth 3.0.2-rc.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!-- This file was generated by @travetto/doc and should not be modified directly -->
|
|
2
|
-
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/auth/DOC.
|
|
2
|
+
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/auth/DOC.tsx and execute "npx trv doc" to rebuild -->
|
|
3
3
|
# Authentication
|
|
4
|
+
|
|
4
5
|
## Authentication scaffolding for the Travetto framework
|
|
5
6
|
|
|
6
7
|
**Install: @travetto/auth**
|
|
@@ -13,12 +14,10 @@ yarn add @travetto/auth
|
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
This module provides the high-level backdrop for managing security principals. The goal of this module is to be a centralized location for various security frameworks to plug into. The primary contributions are:
|
|
16
|
-
|
|
17
|
-
|
|
18
17
|
* Standard Types
|
|
19
18
|
* Authentication Contract
|
|
20
19
|
* Authorization Contract
|
|
21
|
-
* Common security-related utilities for
|
|
20
|
+
* Common security-related utilities for
|
|
22
21
|
* Checking permissions
|
|
23
22
|
* Generating passwords
|
|
24
23
|
|
|
@@ -102,15 +101,14 @@ export interface Authorizer<P extends Principal = Principal> {
|
|
|
102
101
|
}
|
|
103
102
|
```
|
|
104
103
|
|
|
105
|
-
Authorizers are generally seen as a secondary step post-authentication. Authentication acts as a very basic form of authorization, assuming the principal store is owned by the application.
|
|
104
|
+
Authorizers are generally seen as a secondary step post-authentication. Authentication acts as a very basic form of authorization, assuming the principal store is owned by the application.
|
|
106
105
|
|
|
107
106
|
The [Authorizer](https://github.com/travetto/travetto/tree/main/module/auth/src/types/authorizer.ts#L8) only requires one method to be defined, and that is `authorizer`. This method receives an authenticated principal as an input, and is responsible for converting that to an authorized principal.
|
|
108
107
|
|
|
109
108
|
### Example
|
|
110
|
-
The [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.") extension is a good example of an authenticator. This is a common use case for simple internal auth.
|
|
109
|
+
The [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.") extension is a good example of an authenticator. This is a common use case for simple internal auth.
|
|
111
110
|
|
|
112
111
|
Overall, the structure is simple, but drives home the primary use cases of the framework. The goals are:
|
|
113
|
-
|
|
114
112
|
* Be able to identify a user uniquely
|
|
115
113
|
* To have a reference to a user's set of permissions
|
|
116
114
|
* To have access to the principal
|
|
@@ -155,17 +153,13 @@ export class AuthUtil {
|
|
|
155
153
|
}
|
|
156
154
|
```
|
|
157
155
|
|
|
158
|
-
`roleMatcher` is probably the only functionality that needs to be explained. The function extends the core allow/deny matcher functionality from [Base](https://github.com/travetto/travetto/tree/main/module/base#readme "Environment config and common utilities for travetto applications.")'s Util class.
|
|
156
|
+
`roleMatcher` is probably the only functionality that needs to be explained. The function extends the core allow/deny matcher functionality from [Base](https://github.com/travetto/travetto/tree/main/module/base#readme "Environment config and common utilities for travetto applications.")'s Util class.
|
|
159
157
|
|
|
160
158
|
An example of role checks could be:
|
|
161
|
-
|
|
162
|
-
|
|
163
159
|
* Admin
|
|
164
160
|
* !Editor
|
|
165
161
|
* Owner+Author
|
|
166
|
-
|
|
167
162
|
The code would check the list in order, which would result in the following logic:
|
|
168
|
-
|
|
169
163
|
* If the user is an admin, always allow
|
|
170
164
|
* If the user has the editor role, deny
|
|
171
165
|
* If the user is both an owner and an author allow
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/auth",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Authentication scaffolding for the Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"directory": "module/auth"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@travetto/base": "^3.0.
|
|
26
|
+
"@travetto/base": "^3.0.3"
|
|
27
27
|
},
|
|
28
28
|
"travetto": {
|
|
29
29
|
"displayName": "Authentication"
|