mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-07 06:03:09 -06:00
Implement CAIP-10 user ID
This commit is contained in:
parent
8e4ee4c229
commit
0bf23cae2f
|
|
@ -29,7 +29,7 @@ import (
|
||||||
type LoginPublicKeyEthereum struct {
|
type LoginPublicKeyEthereum struct {
|
||||||
// https://github.com/tak-hntlabs/matrix-spec-proposals/blob/main/proposals/3782-matrix-publickey-login-spec.md#client-sends-login-request-with-authentication-data
|
// https://github.com/tak-hntlabs/matrix-spec-proposals/blob/main/proposals/3782-matrix-publickey-login-spec.md#client-sends-login-request-with-authentication-data
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Address string `json:"address"`
|
UserId string `json:"user_id"`
|
||||||
Session string `json:"session"`
|
Session string `json:"session"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Signature string `json:"signature"`
|
Signature string `json:"signature"`
|
||||||
|
|
@ -51,7 +51,7 @@ func CreatePublicKeyEthereumHandler(
|
||||||
pk.config = config
|
pk.config = config
|
||||||
pk.userAPI = userAPI
|
pk.userAPI = userAPI
|
||||||
// Case-insensitive
|
// Case-insensitive
|
||||||
pk.Address = strings.ToLower(pk.Address)
|
pk.UserId = strings.ToLower(pk.UserId)
|
||||||
|
|
||||||
return &pk, nil
|
return &pk, nil
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +65,7 @@ func (pk LoginPublicKeyEthereum) GetType() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *jsonerror.MatrixError) {
|
func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *jsonerror.MatrixError) {
|
||||||
localPart, err := userutil.ParseUsernameParam(pk.Address, &pk.config.Matrix.ServerName)
|
localPart, err := userutil.ParseUsernameParam(pk.UserId, &pk.config.Matrix.ServerName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// userId does not exist
|
// userId does not exist
|
||||||
return "", jsonerror.Forbidden("the address is incorrect, or the account does not exist.")
|
return "", jsonerror.Forbidden("the address is incorrect, or the account does not exist.")
|
||||||
|
|
@ -110,7 +110,7 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri
|
||||||
func (pk LoginPublicKeyEthereum) CreateLogin() *Login {
|
func (pk LoginPublicKeyEthereum) CreateLogin() *Login {
|
||||||
identifier := LoginIdentifier{
|
identifier := LoginIdentifier{
|
||||||
Type: "m.id.publickey",
|
Type: "m.id.publickey",
|
||||||
User: pk.Address,
|
User: pk.UserId,
|
||||||
}
|
}
|
||||||
login := Login{
|
login := Login{
|
||||||
Identifier: identifier,
|
Identifier: identifier,
|
||||||
|
|
|
||||||
|
|
@ -775,7 +775,7 @@ func handleRegistrationFlow(
|
||||||
if isCompleted {
|
if isCompleted {
|
||||||
sessions.addCompletedSessionStage(sessionID, authType)
|
sessions.addCompletedSessionStage(sessionID, authType)
|
||||||
} else {
|
} else {
|
||||||
newPublicKeyAuthSession(&r)
|
newPublicKeyAuthSession(&r, sessions, sessionID)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "":
|
case "":
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ import (
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newPublicKeyAuthSession(request *registerRequest) {
|
func newPublicKeyAuthSession(request *registerRequest, sessions *sessionsDict, sessionID string) {
|
||||||
|
sessions.sessions[sessionID] = append(sessions.sessions[sessionID], authtypes.LoginTypePublicKey)
|
||||||
// Public key auth does not use password. But the registration flow
|
// Public key auth does not use password. But the registration flow
|
||||||
// requires setting a password in order to create the account.
|
// requires setting a password in order to create the account.
|
||||||
// Create a random password to satisfy the requirement.
|
// Create a random password to satisfy the requirement.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue