nameid-format:emailAddress is used when using email as nameid format.what is the proper nameid format when using username as namid field - saml

NameIDFormat="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" we are using if we need to authenticate a user based on email address.if we need to use username as name id field what should be the nameid format.i got confused .Could any one can help what would be the correct nameid for to authenticate user with username and what would be the consequences if we use nameid-format as "unspecified" please help and i am new to saml concept.

Yes, you should use NameID format urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified instead, but you have to make sure that the IdP uses the correct value for the subject. It has to be configured and is not selected only because you use a sepcific NameID format.

Related

REST API parameter with multiple value types

I have the API route /api/users/:user_id, which takes a number as a parameter.
I want to have now the same route, but taking the username instead of the id, like this: /api/users/:username.
In my code, I have the route set up as /api/users/:user and I check the user URI parameter and do different actions if it is a number or a string.
Is it good practice / efficient to have the same route, but with a different parameter type? Both the username and user id's are unique.
It works, I just want to know if this is a practical solution, or if I should do separate routes.
we solved it by parsing the path variable.
psuedo code
long id;
String name;
try{
id = parselong(input);
}catch(parse exception){
name = input;
}
findbynameorid(id,name)
select * from customer where name = ? or id = ?
Assuming that both IDs and usernames are unique, it's valid solution.
Regarding implementation, you could use a regular expression to match the user identifier and check if it's an ID or a username.
It isn't really "good practice" to share a route parameter on a route, but as long as the IDs and usernames are both unique, you should be fine. Both act as unique identifiers for a user so both can be used to find the user in that route.
You can accept both the ID and username as the same parameter by first making the route param more permissive. Next, you can use the following (pseudo) query to look up whether that param matches the ID or the username:
SELECT id, name FROM users WHERE id={param} OR username={param}
Remember to pass that param in as a real query parameter; do NOT simply concatenate strings. Doing so will open you up to an SQL injection attack.
Solution
Make Parameter value as string and send one Request parameter as additional flag which describe request mode.
/api/users/:user_key?type=boolean > true(default) userid & false for username or vice versa.
Modify your api which then can answer two different apis
/api/users/user/userid/:id & /api/users/user/username/:name
Recommended
Above can resolve your issue. But is not recommended way of dealing with fetching user profile information using REST api. Presuming you will introduced user authentication in you rest application.
Self api : /api/users/me : this will fetch user info of the once who is currently logged with respect to that session/token.
User api : api/users/:id : this will fetch fetch specific user info
Username api: api/users?filters={username=some_username, }: this will fetch info of those users which have username matching with given filter.

REST GET URL Naming

What is the best way to design or name an API URL that would get a specific user with a given unique identifier? I'm using cognitoId as the unique identifier.
Which of the following should I use?
/profiles/profile, then pass the cognitoId as URL Query String Parameters
/profiles/{id}
/profiles/profile then check 'Invoke with caller credentials'
If it is an API where any authorized user can get anyone's username by passing a unique ID, then you could use something like this: /profiles/{id} For example, https://api.github.com/user/1
If it is an API that returns the username of the caller by using the cognito ID, then /profiles/profile should work. See $context.identity variables in documentation to fetch the cognito ID.

Facebook API - Custom Audience from contact data

does any one has experience with using Custom Audience API in order to create audience for contact data of people outside of U.S.?
Part of the API which i refer to is: https://developers.facebook.com/docs/marketing-api/reference/custom-audience/users/
As you can see, documentation lacks of explanation in what format should be data for COUNTRY field provided. Also I don't know how to format data for ST field if the country is outside of US. Should I use some region name or just leave it blank?
I uploaded 1000 users and nobody has been recognized so I suppose that I just did not format data properly.
Sample request: payload={"schema":["FN","LN","CT","ST","COUNTRY"],"is_raw":true,"data":[["adam","nowak","wroclaw","","poland"]]}&access_token=____&format=json
As you can see I left state field blank, and provided country in English translation and lower caps. It is possible that valid value is e.g. PL a not "poland". Also any information about what should be filled in state field would help me a lot.
Thanks in advance.

woocommerce customer Fetch with time filter

I am requesting customer data using Rest Api of woocommerce. Woocommerce api documentation says
"All endpoints (except for customer orders) support date filtering via created_at_min and created_at_max as ?filter[] parameters. e.g. ?filter[created_at_min]=2013-12-01".
However, when I am giving date filter in request URL it results in blank response!!
My question is,can the customer data be fetched via date filter in woocommerce.
Thanks.
You can pass Filter with time in REST API of WooCommerce.
Just pass the filter in H:i:s format.
Note : while trying to generate the signature, I found, the URL encoding needs to be done twice because of extra space between DateTime filter criteria. Just encode the clean text once to get RFC3986 encoding, and do it again to generate the signature. Pass the first encoded string and append the generated signature. I saw the filter to be working.

Difference between setIdentity and setCredential in Zend Framework

What is the difference between setIdentity and setCredential in Zend Framework?
$authAdapter->setIdentityColumn('username')
->setCredentialColumn('password');
$authAdapter->setIdentity($data['username'])
->setCredential($data['password']);
Please help me I need some detailed explanation.
identityColumn: This is the name of the database table column used to represent the identity. The identity column must contain unique values, such as a username or e-mail address.
credentialColumn: This is the name of the database table column used to represent the credential. Under a simple identity and password authentication scheme, the credential value corresponds to the password. See also the credentialTreatment option.
Basically, setIdentity tells the system to set a username and setCredential tells the system to set the provided password for authentication.
Hope it helps.
Ref: Zend Table