1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

[sso] give informations about the expected data in sso mapping

This commit is contained in:
Sylvain 2016-09-14 16:41:45 +02:00
parent e3cb5456ed
commit 50543b8d09
8 changed files with 75 additions and 11 deletions

View File

@ -103,8 +103,8 @@ Application.Controllers.controller "AuthentificationController", ["$scope", "$st
##
# Page to add a new authentication provider
##
Application.Controllers.controller "NewAuthenticationController", ["$scope", "$state", "$rootScope", "dialogs", "growl", "mappingFieldsPromise", "authProvidersPromise", "AuthProvider", '_t'
, ($scope, $state, $rootScope, dialogs, growl, mappingFieldsPromise, authProvidersPromise, AuthProvider, _t) ->
Application.Controllers.controller "NewAuthenticationController", ["$scope", "$state", "$rootScope", "$uibModal", "dialogs", "growl", "mappingFieldsPromise", "authProvidersPromise", "AuthProvider", '_t'
, ($scope, $state, $rootScope, $uibModal, dialogs, growl, mappingFieldsPromise, authProvidersPromise, AuthProvider, _t) ->
$scope.authMethods = METHODS
@ -178,6 +178,30 @@ Application.Controllers.controller "NewAuthenticationController", ["$scope", "$s
$scope.cancel = ->
$state.go('app.admin.members')
##
# Open a modal allowing to specify the data mapping for the given field
##
$scope.defineDataMapping = (mapping) ->
$uibModal.open
templateUrl: '<%= asset_path "admin/authentications/_data_mapping.html" %>'
size: 'md'
resolve:
field: -> mapping
controller: ['$scope', '$uibModalInstance', 'field', ($scope, $uibModalInstance, field) ->
## parent field
$scope.field = field
## close and save the modifications
$scope.ok = ->
console.log('TODO')
$uibModalInstance.close()
## do not save the modifications
$scope.cancel = ->
$uibModalInstance.dismiss()
]
]

View File

@ -0,0 +1,15 @@
<div class="modal-header">
<h3 class="modal-title"><span translate>{{ 'data_mapping' }}</span> : {{field.local_field[0]}}</h3>
</div>
<div class="modal-body m-lg">
<div>
<span translate>{{ 'expected_data_type' }}</span> : {{field.local_field[1]}}
</div>
<form name="mappingForm">
</form>
</div>
<div class="modal-footer">
<!--<button class="btn btn-primary" ng-click="ok()" ng-disabled="!mappingForm.$valid" translate>{{ 'confirm' }}</button>-->
<button class="btn btn-warning" ng-click="cancel()" translate>{{ 'cancel' }}</button>
</div>

View File

@ -16,11 +16,14 @@
<tbody>
<tr ng-repeat="m in provider.providable_attributes.o_auth2_mappings_attributes" ng-if="!m._destroy">
<td class="text-c">{{m.local_model}}</td>
<td>{{m.local_field}}</td>
<td>{{m.local_field[0]}}</td>
<td>{{m.api_endpoint}}</td>
<td>{{m.api_data_type}}</td>
<td>{{m.api_field}}</td>
<td>
<button class="btn btn-info" ng-click="defineDataMapping(m)">
<i class="fa fa-info-circle"></i>
</button>
<button class="btn btn-danger" ng-click="m._destroy = true">
<i class="fa fa-trash-o"></i>
</button>
@ -38,7 +41,7 @@
<td ng-class="{'has-error': mappingForm['auth_mapping[local_field]'].$dirty && mappingForm['auth_mapping[local_field]'].$invalid}">
<select class="form-control"
name="auth_mapping[local_field]"
ng-options="field for field in mappingFields[newMapping.local_model]"
ng-options="field[0] for field in mappingFields[newMapping.local_model]"
ng-model="newMapping.local_field"
required>
</select>

View File

@ -37,4 +37,16 @@ class Profile < ActiveRecord::Base
def str_gender
gender ? 'male' : 'female'
end
def self.mapping
# we protect some fields as they are designed to be managed by the system and must not be updated externally
blacklist = %w(id user_id created_at updated_at)
# model-relationships must be added manually
additional = [%w(avatar string), %w(address string), %w(organization_name string), %w(organization_address string)]
Profile.column_types
.map{|k,v| [k, v.type.to_s]}
.delete_if { |col| blacklist.include?(col[0]) }
.concat(additional)
end
end

View File

@ -336,6 +336,17 @@ class User < ActiveRecord::Base
end
end
def self.mapping
# we protect some fields as they are designed to be managed by the system and must not be updated externally
blacklist = %w(id encrypted_password reset_password_token reset_password_sent_at remember_created_at
sign_in_count current_sign_in_at last_sign_in_at current_sign_in_ip last_sign_in_ip confirmation_token confirmed_at
confirmation_sent_at unconfirmed_email failed_attempts unlock_token locked_at created_at updated_at stp_customer_id slug
provider auth_token merged_at)
User.column_types
.map{|k,v| [k, v.type.to_s]}
.delete_if { |col| blacklist.include?(col[0]) }
end
protected
def confirmation_required?
false

View File

@ -1,9 +1,4 @@
# we protect some fields are they are designed to be managed by the system and must not be updated externally
json.user User.mapping
json.user User.column_names - %w(id encrypted_password reset_password_token reset_password_sent_at remember_created_at
sign_in_count current_sign_in_at last_sign_in_at current_sign_in_ip last_sign_in_ip confirmation_token confirmed_at
confirmation_sent_at unconfirmed_email failed_attempts unlock_token locked_at created_at updated_at stp_customer_id slug
provider auth_token merged_at)
json.profile Profile.column_names - %w(id user_id created_at updated_at) + %w(avatar address organization_name organization_address)
json.profile Profile.mapping

View File

@ -248,6 +248,8 @@ en:
provider_name_is_required: "Provider name is required."
authentication_type: "Authentication type"
authentication_type_is_required: "Authentication type is required."
data_mapping: "Data mapping"
expected_data_type: "Expected data type"
oauth2:
# edition/creation form of an OAuth2 authentication provider

View File

@ -248,6 +248,8 @@ fr:
provider_name_is_required: "Le nom du fournisseur est requis."
authentication_type: "Type d'authentification"
authentication_type_is_required: "Le type d'authentification est requis."
data_mapping: "Correspondance des données"
expected_data_type: "Type de données attendues"
oauth2:
# formulaire d'édition/création d'un fournisseur d'authentification de type OAuth2