Add SAML random usernames choice

pull/16372/head
Moisés Calzado 3 years ago
parent 2f63abe18a
commit 58a611bd3f

@ -159,6 +159,7 @@ class Admin::OrganizationsController < Admin::AdminController
@organization.auth_github_enabled = attributes[:auth_github_enabled]
@organization.strong_passwords_enabled = attributes[:strong_passwords_enabled]
@organization.password_expiration_in_d = attributes[:password_expiration_in_d]
@organization.random_saml_username = attributes[:random_saml_username]
@organization.update_in_central
@organization.save(raise_on_failure: true)

@ -35,8 +35,8 @@ module Carto
mapzen_routing_block_price: @organization.mapzen_routing_block_price,
geocoder_provider: @organization.geocoder_provider,
isolines_provider: @organization.isolines_provider,
routing_provider: @organization.routing_provider,
map_views_quota: @organization.map_views_quota,
routing_provider: @organization.routing_provider,
map_views_quota: @organization.map_views_quota,
twitter_datasource_quota: @organization.twitter_datasource_quota,
map_view_block_price: @organization.map_view_block_price,
geocoding_block_price: @organization.geocoding_block_price,
@ -49,7 +49,8 @@ module Carto
admin_email: @organization.admin_email,
avatar_url: @organization.avatar_url,
user_count: @organization.users.count,
password_expiration_in_d: @organization.password_expiration_in_d
password_expiration_in_d: @organization.password_expiration_in_d,
random_saml_username: @organization.random_saml_username
}
end

@ -186,10 +186,17 @@ class SessionsController < ApplicationController
return
end
organization_id = warden.env['warden.options'][:organization_id]
organization = Carto::Organization.find(organization_id)
saml_email = warden.env['warden.options'][:saml_email]
username = CartoDB::UserAccountCreator.email_to_username(saml_email)
if organization.random_saml_username
username = CartoDB::UserAccountCreator.random_saml_username
else
username = CartoDB::UserAccountCreator.email_to_username(saml_email)
end
unique_username = Carto::UsernameProposer.find_unique(username)
organization_id = warden.env['warden.options'][:organization_id]
create_user(
username: unique_username,

@ -84,7 +84,7 @@ module CartodbCentralSynchronizable
salesforce_datasource_enabled geocoder_provider
isolines_provider routing_provider engine_enabled builder_enabled
mapzen_routing_quota mapzen_routing_block_price no_map_logo auth_github_enabled
password_expiration_in_d inherit_owner_ffs)
password_expiration_in_d inherit_owner_ffs random_saml_username)
when :update
%i(seats viewer_seats quota_in_bytes display_name description website
discus_shortname twitter_username geocoding_quota map_views_quota
@ -96,7 +96,7 @@ module CartodbCentralSynchronizable
salesforce_datasource_enabled geocoder_provider
isolines_provider routing_provider engine_enabled builder_enabled
mapzen_routing_quota mapzen_routing_block_price no_map_logo auth_github_enabled
password_expiration_in_d inherit_owner_ffs)
password_expiration_in_d inherit_owner_ffs random_saml_username)
end
elsif user?
%i(account_type admin org_admin crypted_password database_host
@ -129,7 +129,7 @@ module CartodbCentralSynchronizable
when :update
allowed_attributes = %i(seats viewer_seats display_name description website discus_shortname twitter_username
auth_username_password_enabled auth_google_enabled password_expiration_in_d
inherit_owner_ffs)
inherit_owner_ffs random_saml_username)
attributes.symbolize_keys.slice(*allowed_attributes).merge(name: name)
end
elsif user?

@ -86,6 +86,21 @@
</div>
</div>
<div class="FormAccount-row">
<div class="FormAccount-rowLabel">
<label class="CDB-Text CDB-Size-medium is-semibold u-mainTextColor">Random SAML Usernames</label>
</div>
<div class="FormAccount-rowData">
<div class="Toggler">
<%= f.check_box :random_saml_username, :id => "random_saml_username" %>
<%= label_tag(:random_saml_username, '') %>
</div>
<div class="u-flex u-lSpace--xl">
<p class="CDB-Text CDB-Size-small u-altTextColor">Generate random usernames for new SAML users.</p>
</div>
</div>
</div>
<div class="FormAccount-row">
<div class="FormAccount-rowLabel">
<label class="CDB-Text CDB-Size-medium is-semibold u-mainTextColor">Password Expiration</label>

@ -0,0 +1,12 @@
require 'carto/db/migration_helper'
include Carto::Db::MigrationHelper
migration(
Proc.new do
add_column :organizations, :random_saml_username, :bool, default: false
end,
Proc.new do
drop_column :organizations, :random_saml_username
end
)

@ -17,8 +17,8 @@
<img :src="userModel.avatar_url">
</div>
<div class="navbar-dropdown-userInfo">
<p class="text is-semibold is-caption">{{userModel.username}}</p>
<p class="text is-small">{{userModel.email}}</p>
<p class="text is-semibold is-caption">{{userModel.organization.random_saml_username ? userModel.email : userModel.username}}</p>
<p v-if="!userModel.organization.random_saml_username" class="text is-small">{{userModel.email}}</p>
</div>
</li>
<li class="navbar-dropdown-iconLink">

@ -1,7 +1,7 @@
<template>
<section class="welcome-section">
<WelcomeFirst v-if="isFirst" :name="name" :userType="userType"></WelcomeFirst>
<WelcomeCompact v-else :name="name" :userType="userType" @newDatesetClicked="onNewDatesetClicked" @newMapClicked="onNewMapClicked">
<WelcomeCompact v-else :name="name" :organization="organization" :userType="userType" @newDatesetClicked="onNewDatesetClicked" @newMapClicked="onNewMapClicked">
<template>
<a v-if="showUpgrade" :href="accountUpgradeURL" class="button is-primary">
{{ $t('HomePage.WelcomeSection.upgradeNow') }}

@ -1,7 +1,7 @@
<template>
<section class="welcome-compact">
<div class="container welcome-compact__content">
<div class="welcome-compact__greeting title is-caption">{{ greeting }}</div>
<div v-if="!randomSAMLUsernames" class="welcome-compact__greeting title is-caption">{{ greeting }}</div>
<div class="welcome-compact__actions">
<OnboardingButton :isFirstTimeViewingDashboard="false"></OnboardingButton>
<button @click="onNewMapClicked" class="button is-primary button--ghost" :disabled="!canCreateMaps">{{ $t(`HomePage.WelcomeSection.actions.createMap`) }}</button>
@ -26,7 +26,8 @@ export default {
OnboardingButton
},
props: {
name: String
name: String,
organization: Object
},
computed: {
greeting () {
@ -37,6 +38,9 @@ export default {
},
canCreateMaps () {
return this.$store.getters['user/canCreateMaps'];
},
randomSAMLUsernames () {
return this.$props.organization.random_saml_username;
}
},
methods: {

@ -108,6 +108,10 @@ module CartoDB
email.strip.split('@')[0].gsub(/[^A-Za-z0-9-]/, '-').downcase
end
def random_saml_username
SecureRandom.hex
end
def user
@user
end

2
package-lock.json generated

@ -1,6 +1,6 @@
{
"name": "cartodb-ui",
"version": "1.0.0-assets.277",
"version": "1.0.0-assets.278",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

@ -1,6 +1,6 @@
{
"name": "cartodb-ui",
"version": "1.0.0-assets.277",
"version": "1.0.0-assets.278",
"description": "CARTO UI frontend",
"repository": {
"type": "git",

Loading…
Cancel
Save