-
Notifications
You must be signed in to change notification settings - Fork 386
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
feat(examples): auth pattern exploration #3406
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Norman <[email protected]>
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
// SendCoins sends `amount` coins from the vault identified by `atok` to the account identified by `to`. | ||
// | ||
// `to` can be an entity ID or an address. | ||
func SendCoins(atok auth.Token, to string, amount int64) { |
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.
Can you write a txtar or share a few maketx
calls that you expect to use with this?
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 is an integration test 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.
Also added txtar here
panic("sent amount must be >= 0") | ||
} | ||
|
||
from := authreg.Authenticate(atok) |
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 prevents me from creating my own authenticator? I don't understand where you expect to whitelist the approved authenticators.
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.
Nothing, the pattern is meant to be extendable.
The registry namespaces the authenticators so you can't authenticate an entity from an other authenticator.
How would you exploit this?
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.
Actually there was a vulnerability in namespacing if you pass paths with ..
, maybe you were refering to that? I added a guard against that 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.
Also if you want to whitelist providers somewhere, you can check the token's Source
or statically import the providers and call their Authenticate function
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 was considering creating a new authenticator, registering it, and then using it for universal acceptance.
I see two secure approaches: one is to implement a whitelist system on the registry itself, and the other is to establish a whitelist system within the contract that checks the authentication.
However, allowing anyone to create an authenticator and contracts to simply "verify if a token is valid" is definitely insecure.
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
I suggest you continue exploring this authentication pattern. Meanwhile, I will consider patterns that are more user-friendly with simple maketx commands, ideally without needing to create hashes or long strings. |
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
Signed-off-by: Norman <[email protected]>
WIP
Authentication pattern using auth token objects
p/demo/auth
: core interfacesr/demo/subacc
: example auth provider that allows to create sub-accounts.To implement an auth provider you only need to create new
auth.Token
andauth.AuthenticateFn
implementationsr/demo/sessions
: another example auth provider that allows to whitelist addresses that can act as the mother accountr/demo/authreg
: auth providers registry, allowing realms to manage ressource for any authentifiable entityr/demo/authbanker
is a basic example of allowing to manipulate coins with auth tokens