omniauth-lifen 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e80b87697473fffbf5b225b44c3ca333c6563694
4
+ data.tar.gz: dadef398e0f727279081649d074c678cbe1e6de7
5
+ SHA512:
6
+ metadata.gz: f3f070db17b95afd84523bf50124b370e181a7c121ae4a5d2fa521a38115ccc87168e2c1b6f876b0b2c22455c98e1ff77c12c719e616292e9304c86bcd5fdfaa
7
+ data.tar.gz: 29cbb354373dabae87bc6e78c7cb03aa9f241c4e3382efc499ac770ee709806c6ebbfd2721499ff2ba1a31cc513d9338563e5bd4507fdb0cc458d8babed1de78
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-planning-de-garde.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Honestica
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ OmniAuth Lifen
2
+ ================
3
+
4
+ This is an [OmniAuth 1.0](https://github.com/intridea/omniauth) strategy for authenticating to [Lifen](https://www.lifen.fr/).
5
+
6
+ Usage
7
+ -----
8
+
9
+ In the Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-lifen'
13
+ ```
14
+
15
+ In a Rails application, put this in `config/initializers/devise.rb`:
16
+
17
+ ```ruby
18
+ config.omniauth :lifen, ENV['LIFEN_APP_ID'], ENV['LIFEN_APP_SECRET']
19
+ ```
20
+
21
+ and follow Devise's [OmniAuth tutorial](https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview) if it's your first OmniAuth's implementation.
22
+
23
+ Restart your server and visit */auth/lifen* and voila !
24
+
25
+
26
+ Authors
27
+ -------
28
+
29
+ * [Etienne Depaulis (@EtienneDepaulis)](https://github.com/EtienneDepaulis)
30
+
31
+ License
32
+ -------
33
+
34
+ Copyright (c) 2017 Etienne Depaulis
35
+
36
+ This source code released under an MIT license.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-lifen/version"
2
+ require "omniauth/strategies/lifen"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Lifen
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Lifen < OmniAuth::Strategies::OAuth2
6
+ option :name, 'lifen'
7
+
8
+ option :client_options, {
9
+ site: 'https://www.lifen.fr/',
10
+ authorize_url: '/oauth/authorize'
11
+ }
12
+
13
+ uid { raw_info['uuid'] }
14
+
15
+ def callback_url
16
+ full_host + script_name + callback_path
17
+ end
18
+
19
+ extra do
20
+ {
21
+ raw_info: {
22
+ email: raw_info['email'],
23
+ first_name: raw_info['firstName'],
24
+ last_name: raw_info['lastName']
25
+ }
26
+ }
27
+ end
28
+
29
+ def raw_info
30
+ @raw_info ||= access_token.get("authentication/api/me").parsed.first
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ # Inspiration from : https://github.com/intridea/oauth2/pull/165
37
+ # Lifen API uses a Content-Type of "application/hal+json;charset=UTF-8" and not "application/json;charset=UTF-8" which is not supported by OAuth2 gem
38
+
39
+ OAuth2::Response.register_parser(:json, ['application/json', 'text/javascript', 'application/hal+json']) do |body|
40
+ MultiJson.load(body) rescue body
41
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../lib/omniauth-lifen/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Etienne Depaulis"]
5
+ gem.email = ["etienne.depaulis@honestica.com"]
6
+ gem.description = "An Omniauth Strategy for Lifen"
7
+ gem.summary = "An Omniauth Strategy for Lifen"
8
+ gem.homepage = "https://github.com/honestica/omniauth-lifen"
9
+
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.name = "omniauth-lifen"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Omniauth::Lifen::VERSION
16
+
17
+ gem.add_dependency 'omniauth', '~> 1.3'
18
+ gem.add_dependency 'omniauth-oauth2', '~> 1.4'
19
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-lifen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Etienne Depaulis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ description: An Omniauth Strategy for Lifen
42
+ email:
43
+ - etienne.depaulis@honestica.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - lib/omniauth-lifen.rb
54
+ - lib/omniauth-lifen/version.rb
55
+ - lib/omniauth/strategies/lifen.rb
56
+ - omniauth-lifen.gemspec
57
+ homepage: https://github.com/honestica/omniauth-lifen
58
+ licenses: []
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.6.8
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: An Omniauth Strategy for Lifen
80
+ test_files: []