Add options to configure token path for oauth

pull/642/head
Rodrigo Nascimento 11 years ago
parent d7ed9540af
commit fe1d71da15
  1. 1
      i18n/en.i18n.json
  2. 10
      packages/rocketchat-custom-oauth/custom_oauth_server.coffee
  3. 9
      packages/rocketchat-lib/settings/server/addOAuthService.coffee
  4. 2
      packages/rocketchat-lib/settings/server/updateServices.coffee

@ -25,6 +25,7 @@
"Accounts_OAuth_Twitter_secret": "Twitter Secret",
"Accounts_OAuth_Custom_ID": "ID",
"Accounts_OAuth_Custom_URL": "URL",
"Accounts_OAuth_Custom_Token_Path": "Token Path",
"Accounts_OAuth_Custom_Secret": "Secret",
"Accounts_OAuth_Custom_Enable": "Enable",
"Add_Members" : "Add Members",

@ -27,11 +27,11 @@ class CustomOAuth
if not Match.test options.serverURL, String
return throw new Meteor.Error 'CustomOAuth: Options.serverURL is required and must be String'
if not Match.test options.tokenURL, String
options.tokenURL = '/oauth/token'
if not Match.test options.tokenPath, String
options.tokenPath = '/oauth/token'
@serverURL = options.serverURL
@tokenURL = options.tokenURL
@tokenPath = options.tokenPath
if Match.test options.addAutopublishFields, Object
Accounts.addAutopublishFields options.addAutopublishFields
@ -44,8 +44,8 @@ class CustomOAuth
response = undefined
try
console.log @serverURL + @tokenURL
response = HTTP.post @serverURL + @tokenURL,
console.log @serverURL + @tokenPath
response = HTTP.post @serverURL + @tokenPath,
headers:
Accept: 'application/json'
'User-Agent': @userAgent

@ -1,6 +1,7 @@
Meteor.methods
addOAuthService: (name) ->
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}" , false, { type: 'boolean', group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Enable'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_url" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_URL'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_id" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_ID'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_secret", '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Secret'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}" , false , { type: 'boolean', group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Enable'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_url" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_URL'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_token_path", '/oauth/token' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Token_Path'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_id" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_ID'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_secret" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Secret'}

@ -22,8 +22,10 @@ updateServices = ->
serviceName = service._id.replace('Accounts_OAuth_Custom_', '')
data.custom = true
data.serverURL = Settings.findOne({_id: "#{service._id}_url"})?.value
data.tokenPath = Settings.findOne({_id: "#{service._id}_token_path"})?.value
new CustomOAuth serviceName.toLowerCase(),
serverURL: data.serverURL
tokenPath: data.tokenPath
if serviceName is 'Facebook'
data.appId = data.clientId

Loading…
Cancel
Save