mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
support for JSONPath syntax in oAuth2 mapping
This commit is contained in:
parent
2bab28dfe6
commit
3a787ea2a0
1
Gemfile
1
Gemfile
@ -14,6 +14,7 @@ gem 'webpacker', '~> 5.x'
|
||||
gem 'jbuilder', '~> 2.5'
|
||||
gem 'jbuilder_cache_multi'
|
||||
gem 'json', '>= 2.3.0'
|
||||
gem 'jsonpath'
|
||||
|
||||
gem 'forgery'
|
||||
gem 'responders', '~> 2.0'
|
||||
|
@ -181,6 +181,8 @@ GEM
|
||||
jbuilder_cache_multi (0.1.0)
|
||||
jbuilder (>= 1.5.0, < 3)
|
||||
json (2.3.1)
|
||||
jsonpath (1.1.0)
|
||||
multi_json
|
||||
jwt (2.2.1)
|
||||
kaminari (1.2.1)
|
||||
activesupport (>= 4.1.0)
|
||||
@ -457,6 +459,7 @@ DEPENDENCIES
|
||||
jbuilder (~> 2.5)
|
||||
jbuilder_cache_multi
|
||||
json (>= 2.3.0)
|
||||
jsonpath
|
||||
kaminari
|
||||
listen (~> 3.0.5)
|
||||
message_format
|
||||
|
@ -64,10 +64,11 @@
|
||||
</td>
|
||||
<td ng-class="{'has-error': mappingForm['auth_mapping[api_field]'].$dirty && mappingForm['auth_mapping[api_field]'].$invalid}">
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
class="form-control help-cursor"
|
||||
placeholder="field_name"
|
||||
ng-model="newMapping.api_field"
|
||||
name="auth_mapping[api_field]"
|
||||
title="{{ 'app.shared.oauth2.api_field_help' | translate }}"
|
||||
required/>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -274,6 +274,7 @@ en:
|
||||
api_endpoint_url: "API endpoint URL"
|
||||
api_type: "API type"
|
||||
api_fields: "API fields"
|
||||
api_field_help: "JsonPath syntax is supported.\n If many fields are selected, the first one will be used.\n Example: $.data[*].name"
|
||||
#machine/training slot modification modal
|
||||
confirm_modify_slot_modal:
|
||||
change_the_slot: "Change the slot"
|
||||
|
@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'omniauth-oauth2'
|
||||
require 'jsonpath'
|
||||
|
||||
module OmniAuth::Strategies
|
||||
# Authentication strategy provided trough oAuth 2.0
|
||||
@ -102,7 +103,7 @@ module OmniAuth::Strategies
|
||||
## NO TRANSFORMATION
|
||||
else
|
||||
puts "@parsed_info[#{local_sym(mapping)}] found in #{raw_info[mapping.api_endpoint.to_sym]}"
|
||||
@parsed_info[local_sym(mapping)] = raw_info[mapping.api_endpoint.to_sym][mapping.api_field]
|
||||
@parsed_info[local_sym(mapping)] = ::JsonPath.new(mapping.api_field).on(raw_info[mapping.api_endpoint.to_sym]).first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user