You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # Go FIDO U2F Library
  2. This Go package implements the parts of the FIDO U2F specification required on
  3. the server side of an application.
  4. [![Build Status](https://travis-ci.org/tstranex/u2f.svg?branch=master)](https://travis-ci.org/tstranex/u2f)
  5. ## Features
  6. - Native Go implementation
  7. - No dependancies other than the Go standard library
  8. - Token attestation certificate verification
  9. ## Usage
  10. Please visit http://godoc.org/github.com/tstranex/u2f for the full
  11. documentation.
  12. ### How to enrol a new token
  13. ```go
  14. app_id := "http://localhost"
  15. // Send registration request to the browser.
  16. c, _ := NewChallenge(app_id, []string{app_id})
  17. req, _ := c.RegisterRequest()
  18. // Read response from the browser.
  19. var resp RegisterResponse
  20. reg, err := Register(resp, c, nil)
  21. if err != nil {
  22. // Registration failed.
  23. }
  24. // Store registration in the database.
  25. ```
  26. ### How to perform an authentication
  27. ```go
  28. // Fetch registration and counter from the database.
  29. var reg Registration
  30. var counter uint32
  31. // Send authentication request to the browser.
  32. c, _ := NewChallenge(app_id, []string{app_id})
  33. req, _ := c.SignRequest(reg)
  34. // Read response from the browser.
  35. var resp SignResponse
  36. newCounter, err := reg.Authenticate(resp, c, counter)
  37. if err != nil {
  38. // Authentication failed.
  39. }
  40. // Store updated counter in the database.
  41. ```
  42. ## Installation
  43. ```
  44. $ go get github.com/tstranex/u2f
  45. ```
  46. ## Example
  47. See u2fdemo/main.go for an full example server. To run it:
  48. ```
  49. $ go install github.com/tstranex/u2f/u2fdemo
  50. $ ./bin/u2fdemo
  51. ```
  52. Open https://localhost:3483 in Chrome.
  53. Ignore the SSL warning (due to the self-signed certificate for localhost).
  54. You can then test registering and authenticating using your token.
  55. ## Changelog
  56. - 2016-12-18: The package has been updated to work with the new
  57. U2F Javascript 1.1 API specification. This causes some breaking changes.
  58. `SignRequest` has been replaced by `WebSignRequest` which now includes
  59. multiple registrations. This is useful when the user has multiple devices
  60. registered since you can now authenticate against any of them with a single
  61. request.
  62. `WebRegisterRequest` has been introduced, which should generally be used
  63. instead of using `RegisterRequest` directly. It includes the list of existing
  64. registrations with the new registration request. If the user's device already
  65. matches one of the existing registrations, it will refuse to re-register.
  66. `Challenge.RegisterRequest` has been replaced by `NewWebRegisterRequest`.
  67. ## License
  68. The Go FIDO U2F Library is licensed under the MIT License.