-
Notifications
You must be signed in to change notification settings - Fork 939
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve(passkeys): improve passkey naming
* add cmd flag for loading aaguid-map file * add aaguid mapper for better passkey naming * bundle aaguid file in docker container * refactor file loading to reuse in multiple occasions Closes: #1027
- Loading branch information
Stefan Jacobi
committed
Jan 23, 2024
1 parent
39cb070
commit abd7213
Showing
11 changed files
with
205 additions
and
17 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
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
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
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
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,48 @@ | ||
package mapper | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gofrs/uuid" | ||
"github.com/knadh/koanf/parsers/json" | ||
"github.com/teamhanko/hanko/backend/config" | ||
"log" | ||
) | ||
|
||
type Aaguid struct { | ||
Name string `json:"name"` | ||
IconLight string `json:"icon_light"` | ||
IconDark string `json:"icon_dark"` | ||
} | ||
|
||
type AaguidMap map[string]Aaguid | ||
|
||
func (w AaguidMap) GetNameForAaguid(aaguid uuid.UUID) *string { | ||
if webauthnAaguid, ok := w[aaguid.String()]; ok { | ||
return &webauthnAaguid.Name | ||
} else { | ||
return nil | ||
} | ||
} | ||
|
||
func LoadAaguidMap(aaguidFilePath *string) AaguidMap { | ||
k, err := config.LoadFile(aaguidFilePath, json.Parser()) | ||
|
||
if err != nil { | ||
log.Println(err) | ||
return nil | ||
} | ||
|
||
if k == nil { | ||
log.Println("no aaguid map file provided. Skipping...") | ||
return nil | ||
} | ||
|
||
var aaguidMap AaguidMap | ||
err = k.Unmarshal("", &aaguidMap) | ||
if err != nil { | ||
log.Println(fmt.Errorf("unable to unmarshal aaguid map: %w", err)) | ||
return nil | ||
} | ||
|
||
return aaguidMap | ||
} |
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
Oops, something went wrong.