WSO2 SCIM 2.0 query filter - multi-value search is not supported. e.g. filter=emails.value co richard01 - scim2

when I follow the WSO2 SCIM 2.0 REST Endpoint(https://docs.wso2.com/display/IS560/apidocs/SCIM2-endpoints/index.html#!/operations#UsersEndpoint#getUser) to search user by some multi-value attribute(e.g. emails). The WSO2 identity server(v5.7.0) returns empty result. The filter string like this -filter=emails.value co abc#abc.com. According to http://www.simplecloud.info/specs/draft-scim-api-00.html#query-resources, the syntax seems good.
curl -v -k --user : https://localhost:9444/scim2/Users?filter=emails.value+co+richard01
the response:
{"totalResults":0,"startIndex":1,"itemsPerPage":0,"schemas":["urn:ietf:params:scim:api:messages:2.0:ListResponse"]

Instead of putting as "emails.value" we need to put "email.<type-name>" which we used to defined when we were creating the user. Email is a multi-valued attribute, so you can add your type and store the value for it. Let's assume here I'm creating the user as follows,
Request:
curl -v -k --user admin:admin --data '{"schemas":[],"name":{"familyName":"jackson","givenName":"kim"},"userName":"kim","password":"kimwso2","emails":[{"value":"kim_j#wso2.com","type":"work"}]}' --header "Content-Type:application/json" https://localhost:9443/scim2/Users
Response:
{"emails":[{"type":"work","value":"kim_j#wso2.com"}],"meta":{"created":"2019-03-26T15:18:47Z","location":"https://localhost:9443/scim2/Users/c40fe2f2-d9c1-4555-a1d1-e6ff3dde9d41","lastModified":"2019-03-26T15:18:47Z","resourceType":"User"},"schemas":["urn:ietf:params:scim:schemas:core:2.0:User","urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"],"name":{"familyName":"jackson","givenName":"kim"},"id":"c40fe2f2-d9c1-4555-a1d1-e6ff3dde9d41","userName":"kim"}
Now let's filter the multi-valued attribute email,
Request:
curl -v -k --user admin:admin https://localhost:9443/scim2/Users?filter=emails.work+co+kim
Response:
{"totalResults":1,"startIndex":1,"itemsPerPage":1,"schemas":["urn:ietf:params:scim:api:messages:2.0:ListResponse"],"Resources":[{"emails":[{"type":"work","value":"kim_j#wso2.com"}],"meta":{"created":"2019-03-26T15:18:47Z","location":"https://localhost:9443/scim2/Users/c40fe2f2-d9c1-4555-a1d1-e6ff3dde9d41","lastModified":"2019-03-26T15:18:47Z","resourceType":"User"},"roles":[{"type":"default","value":"Internal/everyone"}],"name":{"givenName":"kim","familyName":"jackson"},"id":"c40fe2f2-d9c1-4555-a1d1-e6ff3dde9d41","userName":"kim"}]}
For more information refer to the documentation here.

Related

Unable to list regex protected branch using Gitlab API

I am trying to get GitLab protected branches of a project using curl API request, getting all the relevant branches of type "xyz", "xyz-*".
But I am unable to get the branch that has a "/" in its name.
Using below curl request which is failing for branch "release/R*" :
curl -H "Content-Type: application/json" --header "PRIVATE-TOKEN: <TOKEN>" "https://xyz.gitlab.com/tools/gitlab/api/v4/projects/492/protected_branches/'release/R*'"
It gives an output {"error":"404 Not Found"}
Need help to get the output for all the branches, irrespective of the regex, if possible.
To use in a curl request the name of a branch that contains / you need to use its encoded form %2F
Change
release/R
To
release%2FR
To test it, try to query for a single branch (https://docs.gitlab.com/ee/api/branches.html#get-single-repository-branch)
For a branch with name E.g. release/Rated
curl --header "PRIVATE-TOKEN: <TOKEN>" "https://example.com/gitlab/api/v4/projects/<project_id>/repository/branches/release%2FRated"

Azure Office 365 Management APIs

I am trying to get a response from Microsofts Office 365 Management API using bash curl commands-
I get the token like this-
TOKEN=$(curl -X POST "https://login.microsoftonline.com/$TENANTID/oauth2/token" -d "grant_type=client_credentials&client_id=$CLIENTID&client_secret=$ACCESSCODE&resource=$RESOURCEURL" | jq -r '.access_token')
And then use the token to fetch the data like this-
RESULT=`curl -X GET -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" https://manage.office.com/api/v1.0/$TENANTID/ServiceComms/Services`
I do get a token back with the first command, so that works fine and my tenant/client/resource strings are correct
But the second one always gives
{
"error":{
"code":"","message":"Authorization has been denied for this request."
}
}
I pretty sure I have access-
What am I missing?
Turns out the resource URL i was using did not match the URL i was requesting data from

Not able to extract Json Data in Apache-NiFi

I have written a below POST command and using "HandleHttpRequest" processor to receive the POST request in Apache NiFi
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"employeeDetails":{"empid":"124","empname": "praveen"}}' http://localhost:7002
I am able to receive the json data in "handleHttpRequest" processor as shown below
when I check the list queue I am able to see the json data
HandleHttpProcessor details
But I want to extract empid and check whether empid of my json data is null or not,I tried
"ExtractText","ReplaceText","UpdateAttribute","EvaluateJsonPath" etc Processors to fetch empolyee details but I am unable to do it.
EvaluateJson path details
I am getting "flowfile did not have a valid JSON content" error in EvaluateJsonPath processor
How do I extract empdata and check whether its null or not?
The problem is not related to NiFi. You should post data with CURL like this (change double quote " to single quote ' after -d):
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"employeeDetails":{"empid":"124","empname": "praveen"}}' http://localhost:7002
I have the exact same two processors you have, additionally, I also have a HandleHTTPResponse added so that my curl command exits neatly without sending additional buffer messages that make the EvaluateJSONPath component fail with invalid JSON error (My guess is this could have been your case as well).
HTTP Request Flow
Also as #Behrouz Seyedi mentioned you would need to use a single quote in your command. This is my curl command
curl -v -H "Content-type: application/json" -X POST -d '{"employeeDetails":{"empid":"124","empname": "praveen"}}' http://localhost:7003
This is the screenshot to the EvaluateJSONPath processor.
This is the response of the EvaluateJSONPath
empid

Unable to get Cognitive Services access token from subscription key

I have tried both key 1 and key 2 from the Azure Resource Management > Keys page with the following, where foo is a direct copy/paste:
curl -X POST "https://api.cognitive.microsoft.com/sts/v1.0/issueToken?Subscription-Key=foo" --data ""
curl -X POST "https://api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key: foo" --data ""
In both cases I get:
{ "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }
Is there something I need to configure so I can I retrieve access tokens for my subscription? My ultimate goal is to use the access token to authenticate with a Custom Speech Service Endpoint. Thanks!
For some reason this URL worked instead of the one in the documentation:
https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken
Here's the complete command:
curl -X POST --header "Ocp-Apim-Subscription-Key:foo" --data "" "https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken"

Update to-many association

Having a many-to-many relationship between users and groups. I would like to know how to update this relationship with SDR. This is what I've tried so far after reading the docs.
curl -X POST -H 'Content-Type: text/uri-list' -d 'http://localhost:8080/rest/users/5' http://localhost:8080/rest/groups/1/users
Expected result: Add user 5 to group 1.
Actual result: 405 Method Not Allowed.
curl -X PUT -H 'Content-Type: text/uri-list' -d 'http://localhost:8080/rest/users/5' http://localhost:8080/rest/groups/1/users
Expected result: Replace all members of group 1 with user 5.
Actual result: Works as expected.
curl -X PUT -H 'Content-Type: text/uri-list' -d #members.txt http://localhost:8080/rest/groups/1/users
Where the file members.txt has:
http://localhost:8080/rest/users/5
http://localhost:8080/rest/users/6
http://localhost:8080/rest/users/7
Expected result: Replace all members of group 1 with the users 5, 6 and 7.
Actual result: Only last user (in this case 7) gets added.
Could someone provide an example on how to ADD a single URI to an association?. Also if possible, how to add or replace an association with multiple URIs?
After re-reading the documentation, it does indeed say POST should add to the collection.
My experience has been to use PATCH to add to the collection.
To further the answer: You should be able to use PUT CONTENT-TYPE: text/uri-list with a content body having multiple URIs. Each URI is separated by a line break "\n"
Try this:
curl -v -X POST -H "Content-Type: text/uri-list" -d "http://localhost:8080/rest/users/5" http://localhost:8080/rest/groups/1/users

Resources