Skip to content

WIP: Jw3t auth#1538

Draft
mikiquantum wants to merge 4 commits intov1.4.0from
jw3t_auth
Draft

WIP: Jw3t auth#1538
mikiquantum wants to merge 4 commits intov1.4.0from
jw3t_auth

Conversation

@mikiquantum
Copy link
Contributor

No description provided.


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

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
Contributor

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
Contributor

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
Contributor

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