-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEW] Drupal oAuth Integration for Rocketchat #6632
Changes from 10 commits
32bd5ae
13c3eee
2102fd9
2125f10
2ac4f8e
7667867
20d00ad
0293b03
eef2d5f
a1589a9
fad1769
7c9d93d
5f98201
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,7 @@ rocketchat:crowd@1.0.0 | |
rocketchat:custom-oauth@1.0.0 | ||
rocketchat:custom-sounds@1.0.0 | ||
rocketchat:dolphin@0.0.2 | ||
rocketchat:drupal@0.0.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you undo all other changes to this file but this line here? Ideally this PR shouldn't be updating other packages, it should only be adding the code needed for drupal. We'd handle the updating of packages seperately There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree I though I had done just that, Will do with the new update as its base. |
||
rocketchat:emoji@1.0.0 | ||
rocketchat:emoji-custom@1.0.0 | ||
rocketchat:emoji-emojione@0.0.1 | ||
|
@@ -250,3 +251,4 @@ webapp@1.3.15 | |
webapp-hashing@1.0.9 | ||
yasaricli:slugify@0.0.7 | ||
yasinuslu:blaze-meta@0.3.3 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#Drupal oAuth Integration module. | ||
This module works in conjunction with the [Rocket.Chat+ Module for Drupal](https://www.drupal.org/project/rocket_chat) | ||
Version 7.x-1.1 or later. | ||
|
||
A full set of instructions for how to connect the 2 are present in the drupal module's documentation. | ||
|
||
Basically to connect the 2 you first setup the oAuth server connection in your drupal, with the proper permissions | ||
("Use OAuth2 Server" => "Anonymous User" = Checked). | ||
|
||
In the Rocket chat you have to do the following: | ||
- fill in the 'Client ID'. | ||
Bear in mind that the Client ID should not be guessable,but is seen in the URL when doing the login. | ||
- fill in the 'Client Secret'. | ||
This should be treated as a Secret Key (like the Secret Key of a TLS certificate). it __must not__ be guesable or | ||
derivable, and is best a Alphanumerical sequence between 16 and 48 cahracters long (longer would be better but longer | ||
than 48 characters can be problem with long URI's) | ||
- fill in the Drupal's BaseURL. | ||
- on the Drupal use the "Restrict redirect URIs" Setting to limit possible exploits. and set the Redirect URI's to | ||
whatever is in the Callback URL (like `https://Rocketchat.example.com/_oauth/drupal` and possibly also the | ||
`https://Rocketchat.example.com/_oauth/drupal?close` URI.). | ||
- Lastly do not forget to Enable the Drupal OAuth and `SAVE CHANGES`. | ||
|
||
When all is a Blue Button with a drupal like logo will apear on the login page of Rocket.Chat+ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* global CustomOAuth */ | ||
|
||
// Drupal Server CallBack URL needs to be http(s)://{rocketchat.server}[:port]/_oauth/drupal | ||
// In RocketChat -> Administration the URL needs to be http(s)://{drupal.server}/ | ||
|
||
const config = { | ||
serverURL: '', | ||
identityPath: '/oauth2/UserInfo', | ||
authorizePath: '/oauth2/authorize', | ||
tokenPath: '/oauth2/token', | ||
scope: 'openid email profile offline_access', | ||
tokenSentVia: 'payload', | ||
usernameField: 'preferred_username', | ||
mergeUsers: true, | ||
addAutopublishFields: { | ||
forLoggedInUser: ['services.drupal'], | ||
forOtherUsers: ['services.drupal.name'] | ||
} | ||
}; | ||
|
||
const Drupal = new CustomOAuth('drupal', config); | ||
|
||
if (Meteor.isServer) { | ||
Meteor.startup(function() { | ||
RocketChat.settings.get('API_Drupal_URL', function(key, value) { | ||
config.serverURL = value; | ||
Drupal.configure(config); | ||
}); | ||
}); | ||
} else { | ||
Meteor.startup(function() { | ||
Tracker.autorun(function() { | ||
if (RocketChat.settings.get('API_Drupal_URL')) { | ||
config.serverURL = RocketChat.settings.get('API_Drupal_URL'); | ||
Drupal.configure(config); | ||
} | ||
}); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"API_Drupal_URL": "Drupal Server URL", | ||
"API_Drupal_URL_Description": "Example: https://domain.com (excluding trailing slash)", | ||
"Accounts_OAuth_Drupal": "Drupal Login Enabled", | ||
"Accounts_OAuth_Drupal_callback_url": "Drupal oAuth2 Redirect URI", | ||
"Accounts_OAuth_Drupal_id": "Drupal oAuth2 Client ID", | ||
"Accounts_OAuth_Drupal_secret": "Drupal oAuth2 Client Secret" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.icon-drupal.service-icon { | ||
display: inline-block; | ||
width: 21px; | ||
height: 28px; | ||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAcCAYAAACOGPReAAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAP8A/wD/oL2nkwAAAcNJREFUSMetlbFrFFEQh7/dJnhpDHcx6SyiRLhLkUKDsRZB8S9IWi2Syj8iVooQ0FLBNlqJRpNO8Br7FLkoRDBooQHhNCr6WTjB48zd7d7uNI+d+c333pt9bx5kNPVGVm1WYF39rTbKhD7zr62XBVwI4MsYF4sCZ9S2uq6mMbbVmWGBx9WW+kGdCN+J+G6pY3mBo2pT/ape6IrNx2qb6mhW4Ii6qf5Ur/TQXI74pjoyCJioa3F8FgdoF0K3pib9hLfiDy9l3NVS6G/3EiyH4GbO+q9E3nJ3oKF+Vx/33Urvkj2K/EZn4JW6l/uY/MsfU9+rzUPHXCz/+jDADvC14Myhrqpf1EpB6LHgrCbqa+BzkiSXikAD/ByopcAUsFUUGLYFTKVABWiXBG0DlRTYB8ZLgo4D+ynQAuolQevAdgq8AM6rk0Vo0R7ngQ3UU+qvvNfzCOhKcE4fOu6r39TpIYHT0XsfdDon45puq7WcwFrk7f1XQvVsdPS3Wd+geMPeRN65XqJZdVf9od5Tz/TZ7t3Q7aqzg2avqnfUg2gQO+pT9WGMO+E/CF21m5H0gU8AV4GLwEmgCnwC3gEbwJMkST4elfsHJbIReGbv9uUAAAAASUVORK5CYII=); | ||
background-repeat: no-repeat; | ||
} | ||
|
||
.button.external-login.drupal { | ||
background-color: #0f85b6; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Package.describe({ | ||
name: 'rocketchat:drupal', | ||
version: '0.0.1', | ||
summary: 'RocketChat settings for Drupal oAuth2' | ||
}); | ||
|
||
Package.onUse(function(api) { | ||
api.versionsFrom('1.0'); | ||
api.use('ecmascript'); | ||
api.use('service-configuration'); | ||
api.use('rocketchat:lib@0.0.1'); | ||
api.use('rocketchat:custom-oauth'); | ||
|
||
// api.use('templating', 'client'); | ||
|
||
api.addFiles('common.js'); | ||
api.addFiles('login-button.css', 'client'); | ||
api.addFiles('startup.js', 'server'); | ||
|
||
api.use('templating', 'client'); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
RocketChat.settings.addGroup('OAuth', function() { | ||
this.section('Drupal', function() { | ||
const enableQuery = { | ||
_id: 'Accounts_OAuth_Drupal', | ||
value: true | ||
}; | ||
|
||
this.add('Accounts_OAuth_Drupal', false, { type: 'boolean' }); | ||
this.add('API_Drupal_URL', '', { type: 'string', public: true, enableQuery, i18nDescription: 'API_Drupal_URL_Description' }); | ||
this.add('Accounts_OAuth_Drupal_id', '', { type: 'string', enableQuery }); | ||
this.add('Accounts_OAuth_Drupal_secret', '', { type: 'string', enableQuery }); | ||
this.add('Accounts_OAuth_Drupal_callback_url', '_oauth/drupal', { type: 'relativeUrl', readonly: true, force: true, enableQuery }); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it necessary to add this? I think our other packages might just add this as a dependency.
@RocketChat/core is there a reason it's not in the packages list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure. I just used the build example and added rocketchat:drupal using the
meteor add rocketchat:drupal
command. that I take it added the lines to the package. I am new to meteor, but expierenced in drupal so do not be afraid to tell me i did something wrong ;) I prefer to do it right than muddle on in a 'wrong' way.