Skip to content

Commit

Permalink
Merge "Revert "persist admin scope for CFAdmin utils""
Browse files Browse the repository at this point in the history
  • Loading branch information
d authored and Gerrit Code Review committed Jan 7, 2013
2 parents 0b75717 + 1869f2b commit 5bc8687
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions lib/cloud_controller.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,27 +43,18 @@ def initialize(config)
token_information = token_coder.decode(auth_token) token_information = token_coder.decode(auth_token)
logger.info("Token received from the UAA #{token_information.inspect}") logger.info("Token received from the UAA #{token_information.inspect}")
uaa_id = token_information['user_id'] if token_information uaa_id = token_information['user_id'] if token_information
scopes = token_information['scope'] if token_information
user = Models::User.find(:guid => uaa_id) if uaa_id user = Models::User.find(:guid => uaa_id) if uaa_id
is_admin = scopes && scopes.include?('cloud_controller.admin')


# Bootstraping mechanism.. # Bootstraping mechanism..
# #
# TODO: replace this with an exteranl bootstraping mechanism. # TODO: replace this with an exteranl bootstraping mechanism.
# I'm not wild about having *any* auto-admin generation code # I'm not wild about having *any* auto-admin generation code
# in the cc. # in the cc.
if user.nil? if (user.nil? && Models::User.count == 0 &&
if is_admin ||
(Models::User.count == 0 &&
@config[:bootstrap_admin_email] && token_information['email'] && @config[:bootstrap_admin_email] && token_information['email'] &&
@config[:bootstrap_admin_email] == token_information['email']) @config[:bootstrap_admin_email] == token_information['email'])
user = Models::User.create(:guid => uaa_id, user = Models::User.create(:guid => uaa_id,
:admin => true, :active => true) :admin => true, :active => true)
end
elsif scopes
# token scope is authoritative
user.admin = is_admin
user.save
end end


VCAP::CloudController::SecurityContext.set(user, token_information) VCAP::CloudController::SecurityContext.set(user, token_information)
Expand Down

0 comments on commit 5bc8687

Please sign in to comment.