Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
b0f61d66
Commit
b0f61d66
authored
Sep 20, 2020
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: rocket.chat auth module
parent
722bff1b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
0 deletions
+95
-0
auth-icon-rocketchat.svg
client/static/svg/auth-icon-rocketchat.svg
+2
-0
authentication.js
server/modules/authentication/rocketchat/authentication.js
+64
-0
definition.yml
server/modules/authentication/rocketchat/definition.yml
+29
-0
No files found.
client/static/svg/auth-icon-rocketchat.svg
0 → 100644
View file @
b0f61d66
<svg
width=
"2500"
height=
"2139"
viewBox=
"0 0 256 219"
xmlns=
"http://www.w3.org/2000/svg"
preserveAspectRatio=
"xMidYMid"
><path
d=
"M255.95 109.307c0-12.853-3.844-25.173-11.43-36.63-6.81-10.283-16.351-19.385-28.355-27.057-23.18-14.806-53.647-22.963-85.782-22.963-10.734 0-21.315.907-31.577 2.705-6.366-5.96-13.82-11.322-21.707-15.56C34.964-10.62.022 9.322.022 9.322s32.487 26.688 27.204 50.08C12.693 73.821 4.814 91.207 4.814 109.307c0 .056.003.115.003.173 0 .057-.003.113-.003.174 0 18.1 7.876 35.486 22.412 49.902C32.509 182.95.022 209.639.022 209.639s34.942 19.939 77.077-.48c7.886-4.238 15.338-9.603 21.707-15.56 10.264 1.796 20.843 2.702 31.577 2.702 32.137 0 62.601-8.151 85.782-22.958 12.004-7.671 21.545-16.77 28.356-27.058 7.585-11.455 11.43-23.781 11.43-36.628 0-.06-.003-.115-.003-.174l.002-.176z"
fill=
"#C1272D"
/><path
d=
"M130.383 40.828c59.505 0 107.746 30.814 107.746 68.824 0 38.007-48.241 68.823-107.746 68.823-13.25 0-25.94-1.532-37.662-4.325-11.915 14.332-38.125 34.26-63.587 27.82 8.282-8.895 20.552-23.926 17.926-48.686-15.262-11.873-24.422-27.07-24.422-43.632-.003-38.013 48.238-68.824 107.745-68.824"
fill=
"#FFF"
/><path
d=
"M130.383 126.18c7.906 0 14.314-6.408 14.314-14.314 0-7.905-6.408-14.313-14.314-14.313-7.905 0-14.313 6.408-14.313 14.313 0 7.906 6.408 14.314 14.313 14.314zm49.764 0c7.905 0 14.314-6.408 14.314-14.314 0-7.905-6.409-14.313-14.314-14.313s-14.313 6.408-14.313 14.313c0 7.906 6.408 14.314 14.313 14.314zm-99.53-.003c7.904 0 14.311-6.407 14.311-14.31 0-7.904-6.407-14.312-14.31-14.312-7.905 0-14.312 6.408-14.312 14.311 0 7.904 6.407 14.311 14.311 14.311z"
fill=
"#C1272D"
/><path
d=
"M130.383 169.42c-13.25 0-25.94-1.33-37.662-3.75-10.52 10.969-32.188 25.714-54.643 25.172-2.959 4.484-6.175 8.15-8.944 11.126 25.462 6.44 51.672-13.486 63.587-27.82 11.723 2.795 24.414 4.325 37.662 4.325 59.027 0 106.962-30.326 107.726-67.915-.764 32.582-48.699 58.861-107.726 58.861z"
fill=
"#CCC"
/></svg>
\ No newline at end of file
server/modules/authentication/rocketchat/authentication.js
0 → 100644
View file @
b0f61d66
const
_
=
require
(
'lodash'
)
/* global WIKI */
// ------------------------------------
// Rocket.chat Account
// ------------------------------------
const
OAuth2Strategy
=
require
(
'passport-oauth2'
).
Strategy
module
.
exports
=
{
init
(
passport
,
conf
)
{
const
siteURL
=
conf
.
siteURL
.
slice
(
-
1
)
===
'/'
?
conf
.
siteURL
.
slice
(
0
,
-
1
)
:
conf
.
siteURL
OAuth2Strategy
.
prototype
.
userProfile
=
function
(
accessToken
,
cb
)
{
this
.
_oauth2
.
get
(
`
${
siteURL
}
/api/v1/me`
,
accessToken
,
(
err
,
body
,
res
)
=>
{
if
(
err
)
{
WIKI
.
logger
.
warn
(
'Rocket.chat - Failed to fetch user profile.'
)
return
cb
(
err
)
}
try
{
const
usr
=
JSON
.
parse
(
body
)
cb
(
null
,
{
id
:
usr
.
_id
,
displayName
:
_
.
isEmpty
(
usr
.
name
)
?
usr
.
username
:
usr
.
name
,
email
:
usr
.
email
,
picture
:
usr
.
avatarUrl
})
}
catch
(
err
)
{
WIKI
.
logger
.
warn
(
'Rocket.chat - Failed to parse user profile.'
)
cb
(
err
)
}
})
}
passport
.
use
(
'rocketchat'
,
new
OAuth2Strategy
({
authorizationURL
:
`
${
siteURL
}
/oauth/authorize`
,
tokenURL
:
`
${
siteURL
}
/oauth/token`
,
clientID
:
conf
.
clientId
,
clientSecret
:
conf
.
clientSecret
,
callbackURL
:
conf
.
callbackURL
,
passReqToCallback
:
true
},
async
(
req
,
accessToken
,
refreshToken
,
profile
,
cb
)
=>
{
try
{
const
user
=
await
WIKI
.
models
.
users
.
processProfile
({
providerKey
:
req
.
params
.
strategy
,
profile
})
cb
(
null
,
user
)
}
catch
(
err
)
{
cb
(
err
,
null
)
}
})
)
},
logout
(
conf
)
{
if
(
!
conf
.
logoutURL
)
{
return
'/'
}
else
{
return
conf
.
logoutURL
}
}
}
server/modules/authentication/rocketchat/definition.yml
0 → 100644
View file @
b0f61d66
key
:
rocketchat
title
:
Rocket.chat
description
:
Communicate and collaborate with your team, share files, chat in real-time, or switch to video/audio conferencing.
author
:
requarks.io
logo
:
https://static.requarks.io/logo/rocketchat.svg
color
:
red accent-3
website
:
https://rocket.chat/
isAvailable
:
true
useForm
:
false
scopes
:
-
openid
-
profile
-
email
props
:
clientId
:
type
:
String
title
:
Client ID
hint
:
Application Client ID
order
:
1
clientSecret
:
type
:
String
title
:
Client Secret
hint
:
Application Client Secret
order
:
2
siteURL
:
type
:
String
title
:
Rocket.chat Site URL
hint
:
The base URL of your Rocket.chat site (e.g. https://example.rocket.chat)
order
:
3
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