-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth doc component #5643
Auth doc component #5643
Conversation
055f2b7
to
b9ae852
Compare
4dc9fa5
to
49833ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't expect such detailed writeups! Nice work 👍have some questions and nitpicks
12a0e1a
to
564296d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only had the chance to review the first file.
|
||
</details> | ||
|
||
By default, `authenticate` is **not** part of the sequence of actions, so you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authenticate
== the authenticate action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, seems the word is confusing, any better suggestion? maybe "authenticate"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authenticate
makes sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 changed to authenticate
An authentication action `AuthenticateFn` is provided by the | ||
`AuthenticateActionProvider` class. | ||
|
||
`AuthenticateActionProvider` is defined as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When reading the original documentation (before the refactoring), I was wondering why we need to include the source code of the provider. If we want to describe what the AuthenticateActionProvider does, would it be better to list them out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it aims to describe the provider with comments in code: there are 3 comments in the code snippet and the 1st one above strategy getter has many lines.
Here is an example of a custom sequence which utilizes the `authentication` | ||
action. | ||
|
||
```ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the todo-jwt example, we are using the default sequence that comes with the scaffolded LB app. Maybe we use that instead? Or explain when we want to create a separate sequence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What i meant is that the sequence.ts is created by default when we're scaffolding the app. In the snippet here seems to guide the users to create a new sequence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhmlau I rephrased it to be:
By default, "authenticate" is not part of the sequence of actions, so you
must modify the default sequence and add the authentication action.
And
Here is an example of a modified sequence which utilizes the
authenticate
action.
e924192
to
afca4b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM, just have some suggestions :D
|
||
</details> | ||
|
||
By default, `authenticate` is **not** part of the sequence of actions, so you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authenticate
makes sense to me.
It is up to the developer to throw the appropriate HTTP error code from within a | ||
custom authentications strategy or its custom services. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is L180 one of these options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agnes512 Yep that's correct.
Parameters of the `@authenticate` decorator can be obtained via dependency | ||
injection using the `AuthenticationBindings.METADATA` binding key. It returns | ||
data of type `AuthenticationMetadata` provided by `AuthMetadataProvider`. The | ||
`AuthenticationStrategyProvider`, discussed in a later section, makes use of | ||
`AuthenticationMetadata` to figure out what **name** you specified as a | ||
parameter in the `@authenticate` decorator of a specific controller endpoint. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this paragraph contains too much information. Is it possible to just provide minimum information to explain the mechanism?
For example ( I might not understand it correctly):
With the binding key AuthenticationBindings.METADATA
, the
AuthenticationStrategyProvider
, which will be discussed in a later section, can figure out what strategy name is specified in the @authenticate
decorator.
Cause I assume that at this point the reader should know how binding key works and @authenticate
decorates the endpoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agnes512 Not really, people don't always read all docs in sequence...personally I feel this paragraph is good and necessary, so I tend to keep it as is.
(but thank you for writing the draft 👍 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
e7b9d8d
to
0e09c6f
Compare
Sub PR for #5598
Update the authentication-component page with new layout.
Given the length of this page, I break it down into sub pages for each topic. I run doc preview to make sure links all work.
Screenshots:
New menu:
Pages:
Overview
Decorator
Action
Strategy
Option
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈