I have soap service with basic authentication. I successfully added service to api manager.
Because of using basic authentication on backend service, i try to change endpoint security like in link .https://apim.docs.wso2.com/en/latest/design/endpoints/endpoint-security/basic-auth/
When try to save and deploy getting error as below. By the way, I tried backend service with authentication on soap, I could get successful response.
ERROR - GlobalThrowableMapper Unrecognized property 'endpointSecurity'
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "endpointSecurity" (class org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIDTO), not marked as ignorable (50 known properties: "endpointImplementationType", "threatProtectionPolicies", "securityScheme", "monetization", "name", "businessInformation", "websubSubscriptionConfiguration", "policies", "workflowStatus", "visibility", "createdTime", "revisionId", "version", "tags", "id", "lifeCycleStatus", "enableSchemaValidation", "scopes", "isDefaultVersion", "responseCachingEnabled", "accessControlRoles", "isRevision", "authorizationHeader", "mediationPolicies", "transport", "wsdlUrl", "operations", "context", "provider", "wsdlInfo", "apiThrottlingPolicy", "advertiseInfo", "visibleTenants", "type", "revisionedApiId", "description", "subscriptionAvailableTenants", "cacheTimeout", "serviceInfo", "corsConfiguration", "subscriptionAvailability", "categories", "keyManagers", "visibleRoles", "hasThumbnail", "endpointConfig", "additionalProperties", "maxTps", "accessControl", "lastUpdatedTime"])
Related
I'm using API Manager to define to connection using oath 2.0. I have done all the configurations and connection is working. But some of the requests comes with the following error
{
"code": "601000",
"type": "Status report",
"message": "Runtime Error",
"description": "Error while building message. Error while building Passthrough stream"
}
and look likes the the response has content type application/fhir+json. I have seen some articles to add the content-type in the axis.xml file. Can someone please advise how I can add this content type in the wso2 api manager so that it recognize this content type.
You can add the following configurations to the repository/conf/deployment.toml.
[[custom_message_builders]]
content_type = "application/fhir+json"
class = "org.apache.synapse.commons.json.JsonStreamBuilder"
[[custom_message_formatters]]
content_type = "application/fhir+json"
class = "org.apache.synapse.commons.json.JsonStreamFormatter"
I am new to WSO2 Identity Server-5.11.0 , I want to search user based on username using scim api however nothing works for me
https://localhost:9443/wso2/scim/Users?userNameEqadmin#wso2.com
https://localhost:9443/wso2/scim/Users?filter=userNameEqadmin#wso2.com
https://localhost:9443/wso2/scim/Users?filter=userName=admin#wso2.com
https://localhost:9443/wso2/scim/Users?filter=userName Eq admin#wso2.com
https://localhost:9443/wso2/scim/Users?filter=username=admin#wso2.com
https://localhost:9443/wso2/scim/Users?filter=usernameEqadmin#wso2.com
Can anyone suggest proper search criteria to use ?
Seems you have used SCIM 1.0 protocol.
It's better to use SCIM 2.0 because latest versions of IS supports SCIM 2.0
Refer: https://is.docs.wso2.com/en/latest/develop/scim2-rest-apis/
So the correct SCIM request for user filtering based on exact username match is:
https://localhost:9443/scim2/Users?filter=userName eq admin#wso2.com
Even if the above request doesn't satisfy your query,
Please verify whether you have followed all the steps in https://is.docs.wso2.com/en/latest/learn/using-email-address-as-the-username/#using-email-address-as-the-username in the same order.
Especially, if you have missed this step you won't be able to filter from username by giving the email.
Login to the management console and configure the Mapped Attribute property of the http://wso2.org/claims/username claim ID that is under Dialect dialectURI http://wso2.org/claims to mail.
You can try this with POSTMAN and I'm getting data
URL
https://{your host here}/t/{tenant domain}/scim2/Users/.search
Authorization
You can give basic Auth for now
body
You can give search variable like this
{
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:SearchRequest"
],
"attributes": [
"userName"
],
"filter": "userName Eq SigningOfficer",
"domain": "PRIMARY",
"startIndex": 1,
"count": 10
}
It is a POST method.
For more reference you can try this link
https://is.docs.wso2.com/en/latest/develop/scim2-rest-apis/#/Groups%20Endpoint/getGroupsByPost
I'm using the following stack for my backend:
Cloud Endpoints
Cloud Run Gateway with ESPv2 => check API keys and validate JWTs
Cloud Run gRPC server implementation
When a change of interest happen I publish a message on pubsub
Now, attached to that pubsub topic I have a push subscription that triggers a Cloud Run method with a service account and a specified audience.
Setup:
Now I need to configure the Cloud Run Gateway to validate the JWT that pubsub generates for the specified service account. This is done in the api_config.yaml as per documentation here: https://cloud.google.com/pubsub/docs/push#jwt_format
The issuer is https://accounts.google.com and the audience in the one I specified in the pubsub subscription.
authentication:
providers:
- id: gcloud
jwks_uri: https://www.googleapis.com/robot/v1/metadata/x509/875517523825-compute#developer.gserviceaccount.com
issuer: https://accounts.google.com
audiences: project.clounrun.admin
rules:
- selector: project.v2.Events.*
requirements:
- provider_id: gcloud
The jwks for this service account can be found here:
https://www.googleapis.com/robot/v1/metadata/x509/SERVICE-ACCOUNT-ID
In my case:
https://www.googleapis.com/robot/v1/metadata/x509/875517523825-compute#developer.gserviceaccount.com
https://cloud.google.com/endpoints/docs/grpc/service-account-authentication#set_up_authentication_in_the_grpc_api_configuration
I've activated debug logs for the ESPv2 and this is what I get when it tries to validate the JWT:
13:07:37.027 request headers complete (end_stream=false):\n\':authority\', \'project-gateway-v2-dev-cuvfttrlpq-de.a.run.app\'\n\':path\', \'/v2/sessions:event\'\n\':method\', \'POST\'\n\'content-type\', \'application/json\'\n\'authorization\', \'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImQwNWVmMjBjNDUxOTFlZmY2NGIyNWQzODBkNDZmZGU1NWFjMjI5ZDEiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJ5aXRub3cuY2xvdW5ydW4uYWRtaW4iLCJhenAiOiIxMDk0NDIwMDAxNjU1ODQ3Nzc4MDciLCJlbWFpbCI6Ijg3NTUxNzUyMzgyNS1jb21wdXRlQGRldmVsb3Blci5nc2VydmljZWFjY291bnQuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV4cCI6MTYwMzgwNzAwMSwiaWF0IjoxNjAzODAzNDAxLCJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJzdWIiOiIxMDk0NDIwMDAxNjU1ODQ3Nzc4MDcifQ.PwLvaBz-_dM3_5VjgzVlaueoRhacUE39FdFuVSfQI2w4V3OD79tIA6t_0cuvE1-kIpNrfDda5RSavVcs4SV4Y5P8AvW5jDtHdCELP3yb8HzVT9nCJlLac-v5ZKuv06syBN9F2Ve7VtZHHZOE2VS4B7uw0Q__1rIVzIllYWBYHkYGUBP2mZ3VhRw9VXARMr-EICanXfETe_MMfoKsX4202L_O4LffPdv16pA5hYtwzKi67gFYuubKI1XNkVQVatQieYQrhkz5jMyNyhVKy8ZY5a2UXagQL7erdsm-uPJo6ujoq0Yxtl8iKMdRv4XfrQSLyFZHCYdO6n2LHJle_FQzCQ\'\n\'content-length\', \'335\'\n\'accept\', \'application/json\'\n\'from\', \'noreply#google.com\'\n\'user-agent\', \'APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)\'\n\'x-cloud-trace-context\', \'c3027b54c6aad09d85ce75f6dcaf07d5/8778433264575104852\'\n\'x-forwarded-for\', \'66.249.82.169\'\n\'x-forwarded-proto\', \'https\'\n\'forwarded\', \'for=\"66.249.82.169\";proto=https\'\n\'accept-encoding\', \'gzip,deflate,br\'
13:07:37.027 Called Filter : setDecoderFilterCallbacks
13:07:37.027 matched operation: project.v2.Events.OnSessionEvent
13:07:37.027 Called Filter : decodeHeaders
13:07:37.027 use filter state value project.v2.Events.OnSessionEvent to find verifier.
13:07:37.028 extract authorizationBearer
13:07:37.028 extract x-goog-iap-jwt-assertion
13:07:37.028 gcloud: JWT authentication starts (allow_failed=false), tokens size=1
13:07:37.028 gcloud: startVerify: tokens size 1
13:07:37.028 gcloud: Verifying JWT token of issuer https://accounts.google.com
13:07:37.028 gcloud: JWT token verification completed with: Jwks doesn\'t have key to match kid or alg from Jwt
13:07:37.028 Called Filter : check complete Jwks doesn\'t have key to match kid or alg from Jwt
13:07:37.028 Sending local reply with details jwt_authn_access_denied
As you can see the jwks doesn't contain the JWT kid. And this is true.
The header of this JWT is this:
{
"alg": "RS256",
"kid": "d05ef20c45191eff64b25d380d46fde55ac229d1",
"typ": "JWT"
}
and the payload is this:
{
"aud": "project.clounrun.admin",
"azp": "109442000165584777807",
"email": "875517523825-compute#developer.gserviceaccount.com",
"email_verified": true,
"exp": 1603807001,
"iat": 1603803401,
"iss": "https://accounts.google.com",
"sub": "109442000165584777807"
}
This indicates that pubsub does indeed use that service account but it looks like that specific kid is missing from the jwks response.
{
"4366ae10d4a79728de14f6f89a628b4fe640140f": "-----BEGIN CERTIFICATE-----\nMIIC+jCCAeKgAwIBAgIIapShdpj8y6QwDQYJKoZIhvcNAQEFBQAwIDEeMBwGA1UE\nAxMVMTA5NDQyMDAwMTY1NTg0Nzc3ODA3MB4XDTIwMDQzMDIyNDE0N1oXDTMwMDQy\nODIyNDE0N1owIDEeMBwGA1UEAxMVMTA5NDQyMDAwMTY1NTg0Nzc3ODA3MIIBIjAN\nBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArvpvYFbpJiXk4cEOo2xXzIFjLZEq\nIe1753Oe00IXmq5u/Glf6H0TdShqSn/mHd283UOeDGyjcz/AZO3iKyGv+GndSfiq\ny9TbXfeinCUoVtLUU500P32Ciej/t8Hf4UZYl6XlBVSMZK5ZVCqdWHs9vfPH8k6w\nSJm456BwjL3xty5AjuBooTSHec92SGe2DYSpMJL9NHGELdSnNRoxEaXpEUBV93vr\nTKfbBKa/1WaumVvIn54rAIMkaFq7dJRFr98U2yfHFvUhMtqAwX7HkdvgM74sjfV0\nduVfVz3T/m/oG/7lCllpI4LhVHpxxuNhimFo5quXjShJLPNEjFbESndMaQIDAQAB\nozgwNjAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIHgDAWBgNVHSUBAf8EDDAK\nBggrBgEFBQcDAjANBgkqhkiG9w0BAQUFAAOCAQEAZqBZCbFswKBxa4S+fvC6qb5c\nF/29sxM4WijC4e+/Ti+e6tcRrf3LyOF0jIpHbHWcwjTiYXX+D+UUmMrgh0ZVLCOR\nTDj29JSIUEhzYsGmBzBBcPLfMO2zl6c0aMdUkO+3vXQoTHUNjcs8UoN6BlPo3oIG\n2BjOXhEmuuUA3BQVDsMIM5g4G5r28WaprV7GaTa4fsyCh9oRquTtqL34CZLxiLXv\ncqK+oRMFU4tsLKvZjcfTeKp3fbXDpo7R1R7/+SyxAJTQOe1uPeAc5qh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iylFKU\nq9nyzrvlTRe0tph7kT6D8WhlnxGDgnDOn9xAB360xh+KPczq7+8DJczSb5145No/\nefrCUpvgkraVe/eTsu8EAjDjk/XPOeV4117EU+PRVV5nitYiVGJ0Z+3V3kHCnqLT\ntTxQlKDRpJ02GjhQRkW03fhLEFr7eu79fiwfjfaFSoAAIrNxBi3mtrhcidu43zD1\n/VXAReH26S129UoYz7fPlsnULX/oUyZPidaKIZ2Fl5N2QTgXnd1PnU3HgesU4HWs\nYJeiq6Z1pFxTw9192VD3MgDSDVQAeHXs+wTQsUHftMcNl7nPWl9YfiPjzD4sNWL3\n8whVkhIN8r4=\n-----END CERTIFICATE-----\n"
}
We have:
4366ae10d4a79728de14f6f89a628b4fe640140f
e0b3368c1646eb88d93b9d0b2d65e2d6fbae27b7
c0191d2d00f89eb1905886a04335a79a124885e1
But no
d05ef20c45191eff64b25d380d46fde55ac229d1
If pubsub is using a different key that where can I find the jwks?
UPDATE:
I verified all my services accounts JWKS links and none of them contain that kid. So this is very strange.
You are using a Google signing key (Google is signing for you).
This means you need to lookup the KID from Google's published public keys.
You will find the public certificate kid here: https://www.googleapis.com/oauth2/v1/certs
For some added context, each service account has a sort of "hidden` key. Google manages and controls this key. When you request an Identity Token from Google, the JWT is signed using this special key. That is why you need to look this up in Google's public certificate list instead of your service account's certificate list.
I have configured google provider via cognito user pool and I am able to login through google and get user information. And I have added many attributes on the attribute mapping page as shown in below screenshot.
The endpoint I am using to get user info is https://docs.aws.amazon.com/cognito/latest/developerguide/userinfo-endpoint.html.
The response data for user info is always:
data: {
identities: '[{"userId":"xxxx","providerName":"Google","providerType":"Google","issuer":null,"primary":true,"dateCreated":1587772412295}]',
email_verified: 'true',
email: 'xxxx#gmail.com',
username: 'Google_1xxxx'
}
Regardless how I update the attribute mappings, I always see above response. Why can't I get additional attributes like picture, given_name, birthday etc. Do I need to set any permission on google side?
In app client setting, I have below configuration:
In authorized scope, I have set: email openid profile
I am using App Engine Standard with the Python 2 runtime and Endpoints Frameworks.
When making a request, the app just returns "Successful" if the request was completed. I am trying to implement authentication so unauthenticated users are not able to complete the request. I've done the following:
Modified my main.py decorator to include issuers and audience:
issuers={'serviceAccount': endpoints.Issuer('[MYSERVICEACCOUNT]', 'https://www.googleapis.com/robot/v1/metadata/x509/[MYSERVICEACCOUNT]')},
audiences={'serviceAccount': ['[MYSERVICENAME]-dot-[MYPROJECT].appspot.com']}
Modifed my main.py method to check for a valid user:
user = endpoints.get_current_user()
if user is None:
raise endpoints.UnauthorizedException('You must authenticate first.')
Regenerated and redeployed my openAPI document. It now has security and securityDefinitions sections.
Updated my app.yaml to reference that Endpoints version.
Redeployed my app
To make an authorized request to my app, I have done the following:
I gave the service account the Service Consumer role on my Endpoints service.
Generate a signed jwt using the generate_jwt function from Google's documentation. I am passing in credentials using the service account's json key file.
payload = json.dumps({
"iat": now,
"exp": now + 3600,
"iss": [MYSERVICEACCOUNT],
"sub": [MYSERVICEACCOUNT],
"aud": [MYSERVICENAME]-dot-[MYPROJECT].appspot.com
})
Make the request using make_jwt_request function from Google's documentation.
headers = {
'Authorization': 'Bearer {}'.format(signed_jwt),
'content-type': 'application/json'}
I am getting 401 Client Error: Unauthorized for url error. Am I missing something?
Your audiences don't match; in your code, you are requiring an audience of [MYSERVICEACCOUNT], but when generating the JWT, your audience is [MYSERVICENAME]-dot-[MYPROJECT].appspot.com. These need to match.
There are few details, which might be worth checking:
The list of allowed audiences should contain the value of aud claim of a client-generated JWT token. This is what Rose has pointed out.
All of the JWT claims presented in sample client documentation are present. Your code is missing the email claim in the JWT payload dictionary.
The method you're accessing requires no specific OAuth scopes. The scopes are set as the scopes field of #endpoints.method decorator.
After opening a support ticket with Google, it turns out Google's documentation was incorrect. The main.py function needs to check for an authenticated user in the below manner:
providers=[{
'issuer': '[YOUR-SERVICE-ACCOUNT]',
'cert_uri': 'https://www.googleapis.com/service_accounts/v1/metadata/raw/[YOUR-SERVICE-ACCOUNT]',
}]
audiences = ['[YOUR-SERVICE-NAME]-dot-[YOUR-PROJECT-NAME].appspot.com']
user = endpoints.get_verified_jwt(providers, audiences, request=request)
if not user:
raise endpoints.UnauthorizedException
After making that change, I got the following error when trying to make an authenticated request:
Encountered unexpected error from ProtoRPC method implementation: AttributeError ('unicode' object has no attribute 'get')
This was caused by how I was generating the payload with json.dumps(). I generated without json.dumps() like below:
payload = {
"iat": now,
"exp": now + 3600,
"iss": [MYSERVICEACCOUNT],
"sub": [MYSERVICEACCOUNT],
"aud": [MYSERVICENAME]-dot-[MYPROJECT].appspot.com
}
These two changes fixed my issue.