Skip to content
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

WIP: Jw3t auth #1538

Draft
wants to merge 4 commits into
base: v1.4.0
Choose a base branch
from
Draft

WIP: Jw3t auth #1538

wants to merge 4 commits into from

Conversation

mikiquantum
Copy link
Contributor

No description provided.


type JW3THeader struct {
Algorithm string `json:"algorithm"`
AddressType string `json:"address-type"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - for the other types that we expose, we use underscores instead of dashes. Maybe we can do that here to keep things consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree, I am just following the community proposed standard https://hackmd.io/Xp1-M5WVRFybdLwjWqXdEw?view#Web3-Authentication-Design-Draft and that is using - instead.

Copy link

@hamidra hamidra Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed it was meant to be underscore. The TOML format was set to underscore but it was not updated for the JSON format. It is fixed in the doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hamidra thanks for the input we will update to _ then

func decodeJW3T(jw3t string) (*JW3THeader, *JW3TPayload, []byte, error) {
fragments := strings.Split(jw3t, ".")
if len(fragments) != 3 {
return nil, nil, nil, errors.New("bad JW3T format")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we use constant errors for cases like these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, sounds good

ProxyType string
}

type Auth struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have an interface for this so we can use mocks in the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, will do that

return nil, err
}

key, err := types.CreateStorageKey(meta, identity.ProxyPallet, identity.ProxiesMethod, proxyPublicKey)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move all this proxy stuff in a separate service that deals with this. I created one on my identities branch, for now I only implemented this:

type API interface {
	GetProxies(ctx context.Context, accountID *types.AccountID) (*types.ProxyStorageEntry, error)
}

Lemme know how you want to proceed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For certain we will do that, since you were working on the proxies interaction, I didnt want to step on each other toes. I was going to do add that as part of your interface once it was in.

Copy link
Contributor Author

@mikiquantum mikiquantum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdamian thanks for the review, If you have any suggestions on the admin/nonadmin or any other code structure approach overall would be great to hear.
Let sync on how to best integrate your work items and this one as seamlessly as possible.


type JW3THeader struct {
Algorithm string `json:"algorithm"`
AddressType string `json:"address-type"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree, I am just following the community proposed standard https://hackmd.io/Xp1-M5WVRFybdLwjWqXdEw?view#Web3-Authentication-Design-Draft and that is using - instead.

ProxyType string
}

type Auth struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, will do that

func decodeJW3T(jw3t string) (*JW3THeader, *JW3TPayload, []byte, error) {
fragments := strings.Split(jw3t, ".")
if len(fragments) != 3 {
return nil, nil, nil, errors.New("bad JW3T format")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, sounds good

return nil, err
}

key, err := types.CreateStorageKey(meta, identity.ProxyPallet, identity.ProxiesMethod, proxyPublicKey)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For certain we will do that, since you were working on the proxies interaction, I didnt want to step on each other toes. I was going to do add that as part of your interface once it was in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants