Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Federation Library
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ganggo
Federation Library
Commits
b960ac10
Commit
b960ac10
authored
Nov 23, 2017
by
zauberstuhl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new webfinger discovery method
parent
d3cb1bd4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
18 deletions
+10
-18
webfinger.go
webfinger.go
+10
-18
No files found.
webfinger.go
View file @
b960ac10
...
...
@@ -19,17 +19,19 @@ package federation
import
(
"encoding/xml"
"
strings
"
"
fmt
"
"errors"
)
type
WebFinger
struct
{
Host
string
Handle
string
Xrd
WebfingerXml
Json
WebfingerJson
}
// TODO XML webfinger is deprecated
// TODO XML webfinger is deprecated but
// still used in host-meta which is required
// for a successful pod-active check
type
WebfingerXml
struct
{
XMLName
xml
.
Name
`xml:"XRD"`
Xmlns
string
`xml:"xmlns,attr"`
...
...
@@ -60,24 +62,14 @@ type WebfingerJsonLink struct {
}
func
(
w
*
WebFinger
)
Discovery
()
error
{
err
:=
FetchXml
(
"GET"
,
w
.
Host
+
"/.well-known/host-meta"
,
nil
,
&
w
.
Xrd
)
url
:=
fmt
.
Sprintf
(
"%s/.well-known/webfinger?resource=acct:%s"
,
w
.
Host
,
w
.
Handle
)
err
:=
FetchJson
(
"GET"
,
url
,
nil
,
&
w
.
Json
)
if
err
!=
nil
{
return
err
}
if
len
(
w
.
Xrd
.
Links
)
<
1
{
return
errors
.
New
(
"XRD Link missing"
)
}
for
_
,
link
:=
range
w
.
Xrd
.
Links
{
if
link
.
Rel
==
"lrdd"
&&
link
.
Template
!=
""
{
err
=
FetchXml
(
"GET"
,
strings
.
Replace
(
link
.
Template
,
"{uri}"
,
"acct:"
+
w
.
Handle
,
1
),
nil
,
&
w
.
Xrd
)
if
err
!=
nil
{
return
err
if
len
(
w
.
Json
.
Links
)
<
1
{
return
errors
.
New
(
"Webfinger Links missing"
)
}
return
nil
}
}
return
errors
.
New
(
"No lrdd rel found in webfinger document!"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment