This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed the usage of ldap_name and relax username
This has been done in two steps: 1. First of all I've introduced the `namespace_id` column to the `users` table. This means that from now own there is no mapping from users and their personal namespaces through the `username` column, from now on it's done with a plain SQL foreign key. 2. From the previous step, we get that restricting the username is no longer needed. Instead, the format of the username has been greatly relaxed, so the only concerns are: - It is unique in the DB. - We can produce a namespace for it. If the username is not a valid namespace name, then the resulting namespace will have its name altered so it can be valid. If it cannot be valid, then user creation will fail (which is very unlikely: this only happens in cases like "?" or something like that). Fixes #732 Fixes #736 Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
- Loading branch information
Showing
24 changed files
with
343 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# SessionFlash adds the `session_flash` method which deals with flashy messages | ||
# on signup/login, while notifying users about their personal namespace. | ||
module SessionFlash | ||
extend ActiveSupport::Concern | ||
|
||
# Sets the flash object accordingly for the given authenticated user. The | ||
# method is the Devise method to be used for greeting the user (e.g. | ||
# `:signed_up`). If method is nil, then a generic greeting will be set. This | ||
# method also notifies users about their personal namespace (and whether it | ||
# changed or not). | ||
def session_flash(user, method) | ||
# First of all we've got a greeting. | ||
if method.nil? | ||
flash[:notice] = "Welcome!" | ||
else | ||
set_flash_message :notice, method unless method.nil? | ||
end | ||
|
||
# This will happen for the first user, which is the admin that has to | ||
# configure the registry. | ||
return if user.namespace.nil? | ||
|
||
# Now inform the user | ||
ns = user.namespace.name | ||
str = " Your personal namespace is '#{ns}'" | ||
if user.username == ns | ||
str += "." | ||
else | ||
str += " (your username was not a valid Docker namespace, so we had to tweak it)." | ||
end | ||
flash[:notice] << str | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddNamespaceIdToUsers < ActiveRecord::Migration | ||
def change | ||
add_reference :users, :namespace, index: true, foreign_key: true, default: nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RemoveIndexOnLdapUsers < ActiveRecord::Migration | ||
def change | ||
remove_index "users", name: "index_users_on_ldap_name" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.