Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
7410aa9b
Commit
7410aa9b
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Fix #1438
parent
ea9c4de4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/server/webfinger.ts
+25
-13
25 additions, 13 deletions
src/server/webfinger.ts
with
25 additions
and
13 deletions
src/server/webfinger.ts
+
25
−
13
View file @
7410aa9b
import
*
as
mongo
from
'
mongodb
'
;
import
*
as
Router
from
'
koa-router
'
;
import
config
from
'
../config
'
;
import
parseAcct
from
'
../acct/parse
'
;
import
User
from
'
../models/user
'
;
import
User
,
{
IUser
}
from
'
../models/user
'
;
// Init router
const
router
=
new
Router
();
...
...
@@ -14,27 +15,38 @@ router.get('/.well-known/webfinger', async ctx => {
}
const
resourceLower
=
ctx
.
query
.
resource
.
toLowerCase
();
const
webPrefix
=
config
.
url
.
toLowerCase
()
+
'
/@
'
;
let
acctLower
;
let
id
;
if
(
resourceLower
.
startsWith
(
webPrefix
))
{
acctLower
=
resourceLower
.
slice
(
webPrefix
.
length
);
if
(
resourceLower
.
startsWith
(
config
.
url
.
toLowerCase
()
+
'
/@
'
))
{
acctLower
=
resourceLower
.
split
(
'
/
'
).
pop
();
}
else
if
(
resourceLower
.
startsWith
(
config
.
url
.
toLowerCase
()
+
'
/users/
'
))
{
id
=
new
mongo
.
ObjectID
(
resourceLower
.
split
(
'
/
'
).
pop
());
}
else
if
(
resourceLower
.
startsWith
(
'
acct:
'
))
{
acctLower
=
resourceLower
.
slice
(
'
acct:
'
.
length
);
}
else
{
acctLower
=
resourceLower
;
}
const
parsedAcctLower
=
parseAcct
(
acctLower
);
if
(
!
[
null
,
config
.
host
.
toLowerCase
()].
includes
(
parsedAcctLower
.
host
))
{
ctx
.
status
=
422
;
return
;
}
let
user
:
IUser
;
if
(
acctLower
)
{
const
parsedAcctLower
=
parseAcct
(
acctLower
);
if
(
!
[
null
,
config
.
host
.
toLowerCase
()].
includes
(
parsedAcctLower
.
host
))
{
ctx
.
status
=
422
;
return
;
}
const
user
=
await
User
.
findOne
({
usernameLower
:
parsedAcctLower
.
username
,
host
:
null
});
user
=
await
User
.
findOne
({
usernameLower
:
parsedAcctLower
.
username
,
host
:
null
});
}
else
{
user
=
await
User
.
findOne
({
_id
:
id
,
host
:
null
});
}
if
(
user
===
null
)
{
ctx
.
status
=
404
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment