Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
8666f497
Commit
8666f497
authored
Apr 11, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ldap identities
parent
24d139ba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
4 deletions
+26
-4
app/models/identity.rb
app/models/identity.rb
+1
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+6
-1
db/migrate/20150411000035_fix_identities.rb
db/migrate/20150411000035_fix_identities.rb
+16
-0
db/schema.rb
db/schema.rb
+3
-3
No files found.
app/models/identity.rb
View file @
8666f497
...
...
@@ -15,4 +15,5 @@ class Identity < ActiveRecord::Base
belongs_to
:user
validates
:extern_uid
,
allow_blank:
true
,
uniqueness:
{
scope: :provider
}
validates
:user_id
,
uniqueness:
{
scope: :provider
}
end
config/initializers/1_settings.rb
View file @
8666f497
...
...
@@ -67,7 +67,7 @@ Settings.ldap['enabled'] = false if Settings.ldap['enabled'].nil?
if
Settings
.
ldap
[
'enabled'
]
||
Rails
.
env
.
test?
if
Settings
.
ldap
[
'host'
].
present?
server
=
Settings
.
ldap
.
except
(
'sync_time'
)
server
[
'provider_name'
]
=
'ldap'
server
[
'provider_name'
]
=
'ldap
main
'
Settings
.
ldap
[
'servers'
]
=
{
'ldap'
=>
server
}
...
...
@@ -80,8 +80,13 @@ if Settings.ldap['enabled'] || Rails.env.test?
server
[
'provider_name'
]
||=
"ldap
#{
key
}
"
.
downcase
server
[
'provider_class'
]
=
OmniAuth
::
Utils
.
camelize
(
server
[
'provider_name'
])
end
unless
Settings
.
ldap
[
'servers'
].
select
{
|
k
,
server
|
server
[
'provider_name'
]
==
"ldapmain"
}.
any?
raise
"Wrong LDAP configuration. The 'main' LDAP section is missing"
end
end
Settings
[
'omniauth'
]
||=
Settingslogic
.
new
({})
Settings
.
omniauth
[
'enabled'
]
=
false
if
Settings
.
omniauth
[
'enabled'
].
nil?
Settings
.
omniauth
[
'providers'
]
||=
[]
...
...
db/migrate/20150411000035_fix_identities.rb
0 → 100644
View file @
8666f497
class
FixIdentities
<
ActiveRecord
::
Migration
def
up
new_provider
=
Gitlab
.
config
.
ldap
.
servers
.
first
.
last
[
'provider_name'
]
# Delete duplicate identities
Identity
.
connection
.
select_one
(
"DELETE FROM identities WHERE provider = 'ldap' AND user_id IN (SELECT user_id FROM identities WHERE provider = '
#{
new_provider
}
')"
)
# Update legacy identities
Identity
.
where
(
provider:
'ldap'
).
update_all
(
provider:
new_provider
)
if
defined?
(
LdapGroupLink
)
LdapGroupLink
.
where
(
'provider IS NULL'
).
update_all
(
provider:
new_provider
)
end
end
def
down
end
end
db/schema.rb
View file @
8666f497
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20150
328132231
)
do
ActiveRecord
::
Schema
.
define
(
version:
20150
411000035
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -336,12 +336,12 @@ ActiveRecord::Schema.define(version: 20150328132231) do
t
.
string
"import_url"
t
.
integer
"visibility_level"
,
default:
0
,
null:
false
t
.
boolean
"archived"
,
default:
false
,
null:
false
t
.
string
"avatar"
t
.
string
"import_status"
t
.
float
"repository_size"
,
default:
0.0
t
.
integer
"star_count"
,
default:
0
,
null:
false
t
.
string
"import_type"
t
.
string
"import_source"
t
.
string
"avatar"
end
add_index
"projects"
,
[
"created_at"
,
"id"
],
name:
"index_projects_on_created_at_and_id"
,
using: :btree
...
...
@@ -459,6 +459,7 @@ ActiveRecord::Schema.define(version: 20150328132231) do
t
.
integer
"notification_level"
,
default:
1
,
null:
false
t
.
datetime
"password_expires_at"
t
.
integer
"created_by_id"
t
.
datetime
"last_credential_check_at"
t
.
string
"avatar"
t
.
string
"confirmation_token"
t
.
datetime
"confirmed_at"
...
...
@@ -466,7 +467,6 @@ ActiveRecord::Schema.define(version: 20150328132231) do
t
.
string
"unconfirmed_email"
t
.
boolean
"hide_no_ssh_key"
,
default:
false
t
.
string
"website_url"
,
default:
""
,
null:
false
t
.
datetime
"last_credential_check_at"
t
.
string
"github_access_token"
t
.
string
"gitlab_access_token"
t
.
string
"notification_email"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment