-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Connect function to existing vault preparation
feat: Add Register Options for WebAuthn authentication feat: Add EncryptedSet interface for keyshare set
- Loading branch information
Showing
4 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package kss | ||
|
||
import "github.com/di-dao/sonr/crypto" | ||
|
||
// KssI is the interface for the keyshare set | ||
type EncryptedSet interface { | ||
Decrypt(key []byte) (Set, error) | ||
PublicKey() crypto.PublicKey | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package auth | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/di-dao/sonr/internal/local" | ||
"github.com/go-webauthn/webauthn/protocol" | ||
"github.com/go-webauthn/webauthn/protocol/webauthncose" | ||
) | ||
|
||
func GetRegisterOptions(ctx context.Context, challenge protocol.URLEncodedBase64) (protocol.PublicKeyCredentialCreationOptions, error) { | ||
return protocol.PublicKeyCredentialCreationOptions{ | ||
Challenge: challenge, | ||
AuthenticatorSelection: defaultAuthenticationSelection(), | ||
RelyingParty: GetRelayingPartyEntity(ctx), | ||
User: GetUserEntity(ctx), | ||
Parameters: defaultRegistrationCredentialParameters(), | ||
}, nil | ||
} | ||
|
||
func GetUserEntity(ctx context.Context) protocol.UserEntity { | ||
snrctx := local.UnwrapContext(ctx) | ||
return protocol.UserEntity{ | ||
ID: snrctx.UserAddress, | ||
DisplayName: snrctx.UserAddress, | ||
CredentialEntity: protocol.CredentialEntity{ | ||
Name: snrctx.UserAddress, | ||
}, | ||
} | ||
} | ||
|
||
func GetRelayingPartyEntity(ctx context.Context) protocol.RelyingPartyEntity { | ||
snrctx := local.UnwrapContext(ctx) | ||
return protocol.RelyingPartyEntity{ | ||
ID: snrctx.ServiceOrigin, | ||
CredentialEntity: protocol.CredentialEntity{ | ||
Name: snrctx.ServiceOrigin, | ||
}, | ||
} | ||
} | ||
|
||
func defaultAuthenticationSelection() protocol.AuthenticatorSelection { | ||
return protocol.AuthenticatorSelection{ | ||
AuthenticatorAttachment: protocol.CrossPlatform, | ||
} | ||
} | ||
|
||
func defaultRegistrationCredentialParameters() []protocol.CredentialParameter { | ||
return []protocol.CredentialParameter{ | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgES256, | ||
}, | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgES384, | ||
}, | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgES512, | ||
}, | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgRS256, | ||
}, | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgRS384, | ||
}, | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgRS512, | ||
}, | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgPS256, | ||
}, | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgPS384, | ||
}, | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgPS512, | ||
}, | ||
{ | ||
Type: protocol.PublicKeyCredentialType, | ||
Algorithm: webauthncose.AlgEdDSA, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters