-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add new authorization example #2257
Conversation
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.
Looks good!
using IceRpc.Features; | ||
using IceRpc.Slice; | ||
|
||
namespace AuthorizationExample; |
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.
Every other example is in module Demo. Why is this one in AuthorizationExample?
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.
The module name corresponds to the example name. I don't think the others should all be called Demo
.
Co-authored-by: Reece Humphreys <reecewh@icloud.com>
Co-authored-by: Jose <pepone@users.noreply.github.com>
Co-authored-by: Jose <pepone@users.noreply.github.com>
Co-authored-by: Jose <pepone@users.noreply.github.com>
Co-authored-by: Jose <pepone@users.noreply.github.com>
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.
Looks good!
Co-authored-by: Jose <pepone@users.noreply.github.com>
Co-authored-by: Jose <pepone@users.noreply.github.com>
Co-authored-by: Jose <pepone@users.noreply.github.com>
I switched from a byte array to a Guid. However I'm not sure how wise this is since the Guid's are generally not cryptography secure, just random. Using securely generated bytes is probably more correct. 🤷♂️ |
module AuthorizationExample; | ||
|
||
/// The authorization token | ||
typealias Token = sequence<uint8>; |
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.
Are we missing an opportunity to illustrate custom here?
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 think that would be beyond the scope of this example.
This PR adds a new example to how to use interceptors and middleware to perform per request authorization. Several features included:
/admin
path that requires all requests to be "authenticated" with a token/hello
path that gives a different greeting if the session feature is present.NOTE: still need to add a few more comments to the code.