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

UserDisplayName of SessionData is unused #139

Closed
leejuyuu opened this issue May 29, 2023 · 2 comments · Fixed by #141
Closed

UserDisplayName of SessionData is unused #139

leejuyuu opened this issue May 29, 2023 · 2 comments · Fixed by #141
Labels
status/needs-triage Issues that need to be triaged. type/potential-bug Potential Bugs

Comments

@leejuyuu
Copy link

Version

0.8.2

Description

The UserDisplayName field in the SessionData struct is never referenced in the package.
I suppose it is designed to store the user information in the methods like BeginRegistration()?
Maybe consider copying from User.WebAuthnDisplayName() or remove this field to avoid confusion.

Reproduction

Run the following code

code
package main

import (
	"log"

	"github.com/go-webauthn/webauthn/webauthn"
)

func main() {
	wconfig := &webauthn.Config{
		RPDisplayName: "Go Webauthn",                               // Display Name for your site
		RPID:          "go-webauthn.local",                         // Generally the FQDN for your site
		RPOrigins:     []string{"https://login.go-webauthn.local"}, // The origin URLs allowed for WebAuthn requests
	}

	w, err := webauthn.New(wconfig)
	if err != nil {
		log.Fatal(err)
	}

	u := user{id: []byte{1, 2, 3}, displayName: "Go Webauthn", name: "webauthn"}
	_, session, err := w.BeginRegistration(u)
	if err != nil {
		log.Fatal(err)
	}

	log.Println("display name: ", session.UserDisplayName)
}

type user struct {
	id                []byte
	displayName, name string
	credentials       []webauthn.Credential
}

func (u user) WebAuthnID() []byte {
	return u.id
}

func (u user) WebAuthnName() string {
	return u.name
}

func (u user) WebAuthnDisplayName() string {
	return u.displayName
}

func (u user) WebAuthnCredentials() []webauthn.Credential {
	return u.credentials
}

func (u user) WebAuthnIcon() string {
	return ""
}

The terminal prints

2023/05/29 11:48:07 display name:  

Expectations

I would expect

2023/05/29 11:48:07 display name:  Go Webauthn

Documentation

No response

@leejuyuu leejuyuu added status/needs-triage Issues that need to be triaged. type/potential-bug Potential Bugs labels May 29, 2023
@james-d-elliott
Copy link
Member

Could you explain what the use case would be? Seems I added this to the session data by mistake and forgot to remove it.

@leejuyuu
Copy link
Author

In my use case, I store the user name, display name, and the SessionData in a session cookie and only add them to our database until the whole webauthn process is completed. However, I can easily move that field into my own struct (actually that's what I'm currently doing).

I totally agree that field can be removed given its existence is not intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/needs-triage Issues that need to be triaged. type/potential-bug Potential Bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants