本站源代码
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.

58 lines
2.1KB

  1. package openid
  2. // 7.3.1. Discovered Information
  3. // Upon successful completion of discovery, the Relying Party will
  4. // have one or more sets of the following information (see the
  5. // Terminology section for definitions). If more than one set of the
  6. // following information has been discovered, the precedence rules
  7. // defined in [XRI_Resolution_2.0] are to be applied.
  8. // - OP Endpoint URL
  9. // - Protocol Version
  10. // If the end user did not enter an OP Identifier, the following
  11. // information will also be present:
  12. // - Claimed Identifier
  13. // - OP-Local Identifier
  14. // If the end user entered an OP Identifier, there is no Claimed
  15. // Identifier. For the purposes of making OpenID Authentication
  16. // requests, the value
  17. // "http://specs.openid.net/auth/2.0/identifier_select" MUST be
  18. // used as both the Claimed Identifier and the OP-Local Identifier
  19. // when an OP Identifier is entered.
  20. func Discover(id string) (opEndpoint, opLocalID, claimedID string, err error) {
  21. return defaultInstance.Discover(id)
  22. }
  23. func (oid *OpenID) Discover(id string) (opEndpoint, opLocalID, claimedID string, err error) {
  24. // From OpenID specs, 7.2: Normalization
  25. if id, err = Normalize(id); err != nil {
  26. return
  27. }
  28. // From OpenID specs, 7.3: Discovery.
  29. // If the identifier is an XRI, [XRI_Resolution_2.0] will yield an
  30. // XRDS document that contains the necessary information. It
  31. // should also be noted that Relying Parties can take advantage of
  32. // XRI Proxy Resolvers, such as the one provided by XDI.org at
  33. // http://www.xri.net. This will remove the need for the RPs to
  34. // perform XRI Resolution locally.
  35. // XRI not supported.
  36. // If it is a URL, the Yadis protocol [Yadis] SHALL be first
  37. // attempted. If it succeeds, the result is again an XRDS
  38. // document.
  39. if opEndpoint, opLocalID, err = yadisDiscovery(id, oid.urlGetter); err != nil {
  40. // If the Yadis protocol fails and no valid XRDS document is
  41. // retrieved, or no Service Elements are found in the XRDS
  42. // document, the URL is retrieved and HTML-Based discovery SHALL be
  43. // attempted.
  44. opEndpoint, opLocalID, claimedID, err = htmlDiscovery(id, oid.urlGetter)
  45. }
  46. if err != nil {
  47. return "", "", "", err
  48. }
  49. return
  50. }
上海开阖软件有限公司 沪ICP备12045867号-1