openam_gitlab 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b33a1efbee07f67dc44f363957c36a0980607eaf
4
+ data.tar.gz: 51251fd46df10d302b27c34a050a7c229c9ba00e
5
+ SHA512:
6
+ metadata.gz: 920166be7e5f6e1f9f8f189df967616c2649b7d7cf85e80e2abf2402b5f4d6d8265b289e88ec72b5e97b046a97d1012ff9b4d04ffd64b518ad11ef2335da8b27
7
+ data.tar.gz: 5fec54503cc26e130958252b427c3d18dbd15d281d373f1e236e62e2931b0c8d418e993eecdf01933edfee8682ac225c4b0cfb6afa6209671c0ecfd2e064e7e8
data/.gitignore ADDED
@@ -0,0 +1,23 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in openam_gitlab.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Wei Zeng
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.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # OpenamGitlab
2
+
3
+ Integration of Gitlab with OpenAM using [OpenamAuth](https://github.com/jnsolutions/openam_auth)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your Gitlab's `Gemfile`:
8
+
9
+ gem 'openam_gitlab'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ #### Install the gem (as described above)
18
+
19
+ #### Create migration file to add token column to User table
20
+
21
+ ```ruby
22
+ rails generate migration add_token_to_users
23
+ ```
24
+ migration example:
25
+ ```ruby
26
+ class AddTokenToUsers < ActiveRecord::Migration
27
+ def change
28
+ add_column :users, :token, :string
29
+ end
30
+ end
31
+ ```
32
+ #### Create a file `openam_config.rb` under `config/initializers`
33
+
34
+ ```ruby
35
+ # config/initializers/openam_config.rb
36
+ OpenamConfig.config do
37
+ openam_url <Path to your openam server>
38
+ end
39
+ ```
40
+
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it ( https://github.com/[my-github-username]/openam_gitlab/fork )
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,9 @@
1
+ module OpenamGitlab
2
+ class Railtie < Rails::Railtie
3
+ config.after_initialize do
4
+ ActionController::Base::ApplicationController.send(:include, OpenamAuth::Authenticate)
5
+ Devise::SessionsController.send(:include, OpenamGitlab::SessionsController)
6
+ ActiveRecord::Base::User.send(:include, OpenamGitlab::User)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module OpenamGitlab
2
+ module SessionsController
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ def destroy
7
+ openam_logout(current_user.token)
8
+ redirect_to :root
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,34 @@
1
+ module OpenamGitlab
2
+ module User
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ attr_accessor :token
7
+
8
+ def self.existing_user_by_token(token)
9
+ where(token: token).first if token
10
+ end
11
+
12
+ def self.update_openam_user(token, hash)
13
+ if user = where({username: hash.fetch('uid'){raise 'uid is missing'}.first}).first
14
+ user.update_column(:token, token)
15
+ else
16
+ user = self.new(openam_user_hash(token, hash))
17
+ user.save(validate: false)
18
+ end
19
+ user
20
+ end
21
+
22
+ class << self
23
+ private
24
+ def openam_user_hash(token, hash)
25
+ uid = hash.fetch('uid').first
26
+ full_name = hash.fetch('cn').first
27
+ email = hash.fetch('mail').first
28
+ { username: uid, name: full_name, email: email, token: token }
29
+ end
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module OpenamGitlab
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ require "openam_auth"
2
+ require "rails"
3
+ require "openam_gitlab/openam_railties"
4
+ require "openam_gitlab/openam_sessions_controller"
5
+ require "openam_gitlab/openam_user"
6
+ require "openam_gitlab/version"
7
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'openam_gitlab/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "openam_gitlab"
8
+ spec.version = OpenamGitlab::VERSION
9
+ spec.authors = ["Wei Zeng", "Krzysztof Kotlarek"]
10
+ spec.email = ["gzzengwei@gmail.com", "kotlarek.krzysztof@gmail.com"]
11
+ spec.summary = %q{Integration of OpenAM authentication for gitlab}
12
+ spec.description = %q{Integration of OpenAM authentication for gitlab}
13
+ spec.homepage = "https://github.com/jnsolutions/openam_gitlab"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "openam_auth"
24
+
25
+ spec.add_runtime_dependency "railties"
26
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openam_gitlab
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Wei Zeng
8
+ - Krzysztof Kotlarek
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: openam_auth
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: railties
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description: Integration of OpenAM authentication for gitlab
71
+ email:
72
+ - gzzengwei@gmail.com
73
+ - kotlarek.krzysztof@gmail.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/openam_gitlab.rb
84
+ - lib/openam_gitlab/openam_railties.rb
85
+ - lib/openam_gitlab/openam_sessions_controller.rb
86
+ - lib/openam_gitlab/openam_user.rb
87
+ - lib/openam_gitlab/version.rb
88
+ - openam_gitlab.gemspec
89
+ homepage: https://github.com/jnsolutions/openam_gitlab
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Integration of OpenAM authentication for gitlab
113
+ test_files: []