Initial commit
This commit is contained in:
commit
37c8c97f9b
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 J. de Faye
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,18 @@
|
|||
Discourse Steam Login
|
||||
=====================
|
||||
|
||||
1. Add your STEAM WEB API KEY obtainable from [steamcommunity.com/dev/apikey](http://steamcommunity.com/dev/apikey). E.g. domain name: `forum.example.org`
|
||||
|
||||
2. SSH into your server.
|
||||
|
||||
3. `cd /var/docker`
|
||||
|
||||
4. Open `containers/app.yml` and make the following changes:
|
||||
|
||||
1. Add the API key to your Discourse Docker configuration file located at `/var/docker/containers/app.yml`. It needs to go under `env:` in the format ` STEAM_WEB_API_KEY: 'KEY'`
|
||||
|
||||
2. Add the git clone of this plugin to the plugin list under `hooks:` below the Discourse Docker Manager plugin like so: `- git clone https://github.com/defaye/discourse-steam-login.git`
|
||||
|
||||
3. Exit and save changes
|
||||
|
||||
5. Run `./launcher rebuild app` to apply the changes.
|
|
@ -0,0 +1,64 @@
|
|||
# name: Steam authentication with Discourse
|
||||
# about: Authenticate with Discourse with Steam
|
||||
# version: 0.2.0
|
||||
# author: J. de Faye, Sam Saffron
|
||||
|
||||
gem 'omniauth-steam', '1.0.3', git: 'https://github.com/reu/omniauth-steam.git'
|
||||
|
||||
class SteamAuthenticator < ::Auth::Authenticator
|
||||
|
||||
def name
|
||||
'steam'
|
||||
end
|
||||
|
||||
def after_authenticate(auth_token)
|
||||
result = Auth::Result.new
|
||||
|
||||
data = auth_token[:info]
|
||||
raw_info = auth_token["extra"]["raw_info"]
|
||||
name = data["name"]
|
||||
steam_uid = auth_token["uid"]
|
||||
|
||||
current_info = ::PluginStore.get('steam', "steam_uid_#{steam_uid}")
|
||||
|
||||
result.user =
|
||||
if current_info
|
||||
User.where(id: current_info[:user_id]).first
|
||||
end
|
||||
|
||||
result.name = name
|
||||
result.extra_data = { steam_uid: steam_uid }
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
def after_create_account(user, auth)
|
||||
data = auth[:extra_data]
|
||||
::PluginStore.set('steam', "steam_uid_#{data[:steam_uid]}",
|
||||
{user_id: user.id })
|
||||
end
|
||||
|
||||
def register_middleware(omniauth)
|
||||
omniauth.provider :steam, ENV['STEAM_WEB_API_KEY']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
auth_provider title: 'with Steam',
|
||||
message: 'Sign in via Steam (Make sure pop up blockers are not enabled).',
|
||||
frame_width: 960,
|
||||
frame_height: 800,
|
||||
authenticator: SteamAuthenticator.new
|
||||
|
||||
register_css <<CSS
|
||||
|
||||
.btn-social.steam {
|
||||
background: #000;
|
||||
color: #EFE;
|
||||
}
|
||||
|
||||
.btn-social.steam:before {
|
||||
content: "b";
|
||||
}
|
||||
|
||||
CSS
|
Loading…
Reference in New Issue