Code Monkey home page Code Monkey logo

saml-client's Introduction

MIT license Maven Central

Dead Simple SAML 2.0 Client

This library implements a very simple SAML 2.0 client that allows retrieving an authenticated identity from a compliant identity provider, using the HTTP POST binding.

It is based on the OpenSAML library, and only provides the necessary glue code to make it work in a basic scenario. This is by no means a complete implementation supporting all the nitty gritty SAML details, but it does perform the basic task of generating requests and validating responses. It's useful if you need to authenticate with SAML but don't want to bring in an uber large framework such as Spring Security.

In order to work, the library must be provided with the xml metadata information that can be obtained from the identity provider. It is also possible to initialize it by directly providing the required values.

As of now, I've tested the library with ADFS and Okta as identity providers.

Maven

Add this dependency to your pom.xml to reference the library:

    <dependency>
      <groupId>com.coveo</groupId>
      <artifactId>saml-client</artifactId>
      <version>5.0.0</version>
    </dependency>

OpenSAML latest versions are strictly hosted on Shibboleth repository. Therefore, to use this library, you need to add this to your pom.xml as well :

  <repositories>
    <repository>
      <id>shibboleth</id>
      <url>https://build.shibboleth.net/maven/releases</url>
    </repository>
  </repositories>

or with Gradle :

repositories {
    maven {
        url 'https://build.shibboleth.net/maven/releases'
    }
    mavenCentral()
}

Usage

SAML authentication process overview

An SAML authentication exchange involves sending an SAML request to the Identity Provider (ADFS, Okta, etc...) and then receiving a signed SAML response. Both the request and the response will be transferred through POST HTTP requests made from the browser (other means of exchanging the data exist, but aren't supported by this library).

This library provide an easy way to generate the SAML request and then supports decoding and validating the answer returned from the Identity Provider. It also provide an helper method to generate the necessary HTML and JavaScript code to properly POST the SAML request.

Creating an instance of SamlClient

    SamlClient client = SamlClient.fromMetadata("MyRelyingPartyIdentifier", "http://some/url/that/processes/assertions", "<your.IDP.metadata.xml>");

Generating a SAML request

    String encodedRequest = client.getSamlRequest();
    String idpUrl = client.getIdentityProviderUrl();
    // redirect to the identity provider, passing the encoded request with the SAMLRequest form parameter.

Processing an SAML response

    String encodedResponse = servletRequest.getParameter("SAMLResponse");
    SamlResponse response = client.decodeAndValidateSamlResponse(encodedResponse);
    String authenticatedUser = response.getNameID();

Generating a SAML logout request (SP initiated SLO)

    String encodedRequest = getLogoutRequest(nameID);
    // redirect to the identity provider, passing the encoded request with the SAMLRequest form parameter.

Generating a SAML logout response (IDP initiated SLO)

    //Allow to inform the IDP the state of the service provider logout
    String encodedRequest = getSamlLogoutResponse(statusCode, statusMessage);
    // redirect to the identity provider, passing the encoded request with the SAMLRequest form parameter.

Using the helpers for servlet requests and responses

    // To initiate the authentication exchange
    client.redirectToIdentityProvider(servletResponse, null);
    ...
    // To process the POST containing the SAML response
    SamlResponse response = client.processPostFromIdentityProvider(servletRequest);
    ...
    // To process the POST containing the SAML Logout Request
    processLogoutRequestPostFromIdentityProvider(servletRequest,nameID)
    ...
    //To process the POST containing the SAML Logout Response 
    processPostLogoutResponseFromIdentityProvider(servletRequest)

Identity Provider Configuration

ADFS

To configure ADFS to work with this library, you should go to the MMC snap-in for ADFS and add a Relying Party Trust with the following properties:

  • In the Identifiers tab, add a Relying Party Identifier that will match the one you'll provide when initializing SamlClient.
  • In the Endpoints tab, add the url that will process SAML responses to the list, using POST for the Binding value.

Then, to obtain the metadata provider XML, load this url in your browser: https://myserver.domain.com/FederationMetadata/2007-06/FederationMetadata.xml

Okta

To configure Okta to work with this library, create an SAML 2.0 application with the following settings:

  • The Single sign on URL should be the URL that processes SAML responses (e.g. assertions).
  • The Audience URI should be a value that matches the one you'll specify when initializing SamlClient.

Encryption

To generate the public / private keys :

openssl req -new -x509 -days 365 -nodes -sha256 -out saml-public-key.crt -keyout saml-private-key.pem
 
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in saml-private-key.pem -out saml-private-key.key
 
openssl pkcs8 -topk8 -nocrypt -inform PEM -in saml-private-key.key -outform DER -out saml-private-key.pk8

To add the keys :

    // To add the keys (is needed only if you have encrypted assertion or if you want to sign documents)
    client.setSPKeys(publicKeyPath,privateKeyPath);

saml-client's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

saml-client's Issues

Issues with Logout

When creating a SamlClient from metadata, it sets identityProviderUrl to the SingleSignOnService location, but nothing ever pulls out the SingleLogoutService. So later if you call one of the logout helpers, it will send a LogoutRequest to the SingSignOnService instead of the SingleLogoutService.

https://github.com/coveooss/saml-client/blob/master/src/main/java/com/coveo/saml/SamlClient.java#L897

To work around this I wrote this code where I hard coded the URL of the SingleLogoutService:

final String logoutRequest = samlClient.getLogoutRequest(userIdentity);

        Map<String, String> values = new HashMap<>();
        values.put("SAMLRequest", logoutRequest);
        if (relayState != null) {
            values.put("RelayState", relayState);
        }

        BrowserUtils.postUsingBrowser(singleLogoutUrl, response, values);

The IDP responded with a 400 "Error processing LogoutRequest. Single Logout Response Service location not found"

I compared the request with a LogoutRequest from a different application that uses spring-security-saml and succeeded, and the main difference I can see is the request that succeeded had a Destination attribute on the root element.

Currently SamlClient only sets that on the login request:
https://github.com/coveooss/saml-client/blob/master/src/main/java/com/coveo/saml/SamlClient.java#L779

But doesn't set that on the logout request:
https://github.com/coveooss/saml-client/blob/master/src/main/java/com/coveo/saml/SamlClient.java#L803

Link between one SAML request and its SAML response

Hi

I would like to link an SAML request to its response. After reading some stuff on internet it seems that the relayState is ment to be used.
Is it the same as defined in redirectToIdentityProvider method ?
And by the way do you know how to get it form an SamlResponse ?

Regards
Eric (again)

Support for HTTP-Redirect

I've written in support for retrieving the HTTP-Redirect information from IdP Metadata and will submit a Pull Request for it. At least the CAS SSO server supports this method for logging into SAML SSO IdPs.

Logout request failed

Hello. I was testing the client with an ADFS identity provider. When sending a logout request to it, an error returns me indicating the following message "SAML logout request and logout response messages must be signed when using SAML HTTP Redirect or HTTP POST binding". How could I fix this issue?
Thanks.

getIdpBinding - handle no bindings specified

I am trying to hookup SAML with PingFederate.

The metadata.xml file generated by their system does NOT include any md:SingleSignOnService... data.

It would be nice for my users if they could just export the metadata.xml and use it as is in my system instead of having to manually add an entry for md:SingleSignOnService

I would like to build up a PR to make getIdpBinding() to return NULL if there were no md:SingleSignOnService at all, vs there were some, but none matched. Then downstream, I will make the places using the results of it handle null by defaulting to the value from assertionConsumerServiceUrl - sort of like the opposite of what you do if its Okta

Support for alternative NameId policy

It's currently possible to modify the AuthnRequest string and replace the name id format, but this does not work when using client request signing.

It would be nice to have a function exposed to set the format of the name id policy, to be used when composing an AuthnRequest.

Any plans to move to OpenSAML 3.x+?

This library looks very useful. Given that OpenSAML 2.x has been EOL'd since July 2016, are there any plans to upgrade to use OpenSAML 3.x?

At the current time, 3.3.0 is the latest version

Logout request

Hello, with this client is it possible to generate a logout request and send it to the IdP so that it also closes the session there? If possible, what would such an implementation look like?
Thanks.

Getting compilation error after adding dependency in pom.xml

I am getting following error while doing maven install. Can some please look into this.

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error: error reading /Users/xxx/.m2/repository/org/opensaml/opensaml/2.6.4/opensaml-2.6.4.jar; invalid LOC header (bad signature)
[ERROR] error: error reading /Users/xxx/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.51/bcprov-jdk15on-1.51.jar; invalid CEN header (bad signature)
[INFO] 2 errors

The assertion cannot be used

Hi All,

How should solved this problem ? Thank you so much. I used Okta SSO .

com.coveo.saml.SamlException: The assertion cannot be used after 2021-09-29T03:13:30.979Z
at com.coveo.saml.ValidatorUtils.enforceConditions(ValidatorUtils.java:133)
at com.coveo.saml.ValidatorUtils.validateAssertion(ValidatorUtils.java:110)
at com.coveo.saml.ValidatorUtils.validate(ValidatorUtils.java:215)
at com.coveo.saml.SamlClient.decodeAndValidateSamlResponse(SamlClient.java:281)
at com.coveo.saml.SamlClient.processPostFromIdentityProvider(SamlClient.java:316)
at com.oktasaml.demo.MyController.index(MyController.java:95)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)

Getting 400 Bad Request for LogoutRequest from Okta

So the LogoutRequest works for Azure Saml.
But for Okta I'm getting a 400 Bad Request.
Well, I'm not sure where to send therequest in the first place, but I assume it's where the LoginRequest goes to.
Though Azure has a separate URL for that.

metadata files

Hi, Can you please how can we convert federationmetadata.xml file to *.md file format. In my application they are not using any xml file but we have only *.md file, now its time to update that file as providers signatures changed I have update metadata info on my code, this is not an issue but I am not getting help any where, by looking into my code closing previously just copy pasted ur samlclient.java code but they used *.md file for metadata it is not there in your code and no guidelines how to create it also.
Please help me on this. Thanks

NoClassDefFound error on Java 11

When running on Java 11, I get a NoClassDefFound error for javax.xml.bind.ValidationException. This is because JAXB was deprecated in Java 9, and removed entirely from Java 11. Two possible fixes:

  1. Use org.xml.sax.SAXException instead
  2. Add a Maven dependency for jaxb-api

I have tried and tested the first way, and it works in 3.0.1 and 4.0.0 snapshot. I can create a pull request for that. Some people might prefer the second way, which I have not tried yet. Is there a preference?

Can't use ForceAuthn attribute in the Authn request

I'm trying to use the client for identity provider redirection, and force authentication in the provider
What I need is to add ForceAuthn="true" to the saml2p:AuthnRequest tag, but I don't see any way to do it in the client. I'm using the client as follows:

SamlClient client = new SamlClient(relyingPartyIdentifier assertionConsumerService, identityProviderUrl, responseIssuer, certs, SamlClient.SamlIdpBinding.POST); 
client.getSamlRequest();
client.redirectToIdentityProvider(response, customerId);

And I can see the ForceAuthn attribute exists in the lib code, but I didn't find how to use it

image

Capturing the Saml Response URL

We are integrating SAML into an existing Java 'Spring MVC' web app (war) that is not using springboot or maven.
Our IDE is Netbeans.

How would we configure an endpoint to receive the SAML Response callback from the idp?
https://www.billgoobs.com/myapp/saml/SSO?SAMLResponse=ghgadhgkjadhgkjahkga

I'm not asking about how to extract the value from the SAMLResponse query string.

My question is how to setup a post endpoint or listener in our java web app that will be hit when the idp makes the https://www.billgoobs.com/myapp/saml/SSO?SAMLResponse=ghgadhgkjadhgkjahkga callback.

Instance SamlClient throws certificate exception

Hi there I am new to SAML and SSO. I was trying to instance SamlClient and Copied my idp Metadata.xml as an argument. The metadata I am using does have ds:X509Certificatetag in it but I am getting "certificate" exception. Can you please let me know why this is happening or is there any workaround that I could try? Thank you!

New tag verison on par with master?

Hi,

I'm curious to know if you are looking to publish a new tag with what's in master now. I'm looking to use this library and get attributes from XML response, but 3.0.2 doesn't have some handy methods like getAttributes

Thanks,
Jimmy

Thank you very much

The saml puzzle me many days! and this client solve it in the simplest way! thanks a lot

Saml Client for Ping ID

We are trying to use this client for Ping ID. How can we use it for Ping ID? If it already works, could you please share some examples.

Thank you

NameID is treated as required rather than optional

SamlClient.decodeAndValidateSamlResponse() fails if the response doesn't contain NameID. It seems like the field used to be required, but isn't anymore at the moment.

Although most IDPs probably do send it, or should be configurable to, we currently have no way of accepting responses without NameID, and no way of convincing IDPs outside of our control to change this (since they are apparently sending out a compliant response).

Could the requirement be dropped, perhaps in favor of a warning, or otherwise have some option of disabling the requirement?

See also this thread: SAML-Toolkits/python-saml#112

XML parse error for LogoutResponse from Azure

Hi.

When I have "Logout URL" configured in Azure SAML, then I'll get a request from Azure containing a SAMLResponse which contains a LogoutResponse.
But the client bails out when parsing the response.

The response seems to be signed.

There's no method to validate LogoutRequest without specifying NameID

Processing a POST containing the SAML logout request method in SamlClient always expect NameID but in my case, I'm not getting NameID as an additional parameter from IDP in the parameters.

The method I'm using is: https://github.com/coveooss/saml-client/blob/7d334b40558aaa02d3931e0db21c8d39dde5f640/src/main/java/com/coveo/saml/SamlClient.java#L871

There should be an overloaded method that should validate the LogoutRequest but without NameID.

Like below.

/**
   * Processes a POST containing the SAML logout request.
   *
   * @param request the {@link HttpServletRequest}.
   * @return An {@link LogoutRequest} object containing information decoded from the SAML Logout
   *         Request.
   * @throws SamlException thrown is an unexpected error occurs.
   */
  public LogoutRequest processLogoutRequestPostFromIdentityProvider(HttpServletRequest request)
      throws SamlException {
    String encodedResponse = request.getParameter(HTTP_REQ_SAML_PARAM);
    return decodeSamlLogoutRequest(encodedResponse, request.getMethod());
  }

Vulnerable for XSW2

We found that saml-client is vulnerable to XSW2 attacks. I have not been able to establish if the cause lays in this library, or the underlying OpenSaml library.

Receiving 400 Bad Request when authenticating with Okta

When redirecting to Okta, I'm receiving a 400 Bad Request error on the Okta side. I'm using the metadata that they provided and all of the URLs appear to match up between my side and the Okta side. Is there a particular Reader I should be using to serialize the metadata.xml? I've used a FileReader, BufferedReader, and InputStreamReader, but all have failed. I suspect that the bad SAML is a problem with the serialization or encoding of the request.

saml-client 4.1.0 could not resolve opensaml 4.2.0 dependencies

Attempting to use saml-client version 4.1.0 fails to build:

[ERROR] Failed to execute goal on project testing: Could not resolve dependencies for project org.example:testing:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: org.opensaml:opensaml-core:jar:4.2.0, org.opensaml:opensaml-saml-api:jar:4.2.0, org.opensaml:opensaml-saml-impl:jar:4.2.0: Could not find artifact org.opensaml:opensaml-core:jar:4.2.0 in artifactory ...

I believe this is because maven central does not have version 4.2.0 yet: https://mvnrepository.com/artifact/org.opensaml/opensaml-core

The latest version in maven central seems to be 4.0.1

unable to get required help to accomplish SLO with okta

unable to use SLO, how to direct request to SLO url

i am trying to saml-client to SP initiated logout with okta , i am able to use SSO login with okta. but i need guidance on how to proceed

public String sendSAMLRequest(String loggedinUser) throws SamlException, FileNotFoundException {
String publicKeyPath = "cert.x509.pem";
String privateKeyPath = "private.pk8";
final String fileSeparator = System.getProperty("file.separator");
final File file = PathUtils.getTempFile(getServerPath(), "metadata", ".xml");
final File directory = FileUtils.getFile(getServerPath(), "WEB-INF" + fileSeparator + "classes");
final File metadatafile = new File(directory + fileSeparator + SamlReportAuditFactory.FILE_NAME);
FileReader fileReader = new FileReader(metadatafile);
SamlClient client = SamlClient.fromMetadata("http://www.okta.com/jlsdjflsjdflsjjlfjlsj", "https://localhost:8443/myapp/rest/sp/consumer", fileReader);

    final File privateKeyFile = new File(directory + fileSeparator + privateKeyPath);

    final File publicKeyFile  = new File(directory + fileSeparator + publicKeyPath);
    client.setSPKeys(publicKeyFile.getAbsolutePath(),privateKeyFile.getAbsolutePath());
    String encodedRequest = client.getLogoutRequest(loggedinUser);
 
    return encodedRequest;
 
}

servletRequest/servletResponse is not defined

String encodedResponse = servletRequest.getParameter("SAMLResponse");
SamlResponse response = client.decodeAndValidateSamlResponse(encodedResponse);
String authenticatedUser = response.getNameID();
client.redirectToIdentityProvider(servletResponse, null);
SamlResponse response1 = client.processPostFromIdentityProvider(servletRequest);

saml-client 4.0.3 dependency convergence issue with maven-enforcer-plugin enabled

Using saml-client version 4.0.3 with maven-enforcer-plugin enabled throws the dependency convergence error:

[ERROR]
Dependency convergence error for org.slf4j:slf4j-api:1.7.7 paths to dependency are:
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-core:3.4.6
      +-io.dropwizard.metrics:metrics-core:3.1.5
        +-org.slf4j:slf4j-api:1.7.7
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-core:3.4.6
      +-net.shibboleth.utilities:java-support:7.5.2
        +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-core:3.4.6
      +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-xmlsec-api:3.4.6
        +-org.opensaml:opensaml-security-api:3.4.6
          +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-xmlsec-api:3.4.6
        +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-soap-api:3.4.6
        +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-messaging-api:3.4.6
        +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-profile-api:3.4.6
        +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-storage-api:3.4.6
        +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-security-impl:3.4.6
        +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-xmlsec-impl:3.4.6
        +-org.apache.santuario:xmlsec:2.0.10
          +-org.slf4j:slf4j-api:1.7.25
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-xmlsec-impl:3.4.6
        +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-soap-impl:3.4.6
        +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.slf4j:slf4j-api:1.7.30
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.slf4j:slf4j-api:1.7.30

[ERROR]
Dependency convergence error for commons-codec:commons-codec:1.10 paths to dependency are:
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-core:3.4.6
      +-net.shibboleth.utilities:java-support:7.5.2
        +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-core:3.4.6
      +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-xmlsec-api:3.4.6
        +-org.opensaml:opensaml-security-api:3.4.6
          +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-xmlsec-api:3.4.6
        +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-soap-api:3.4.6
        +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-messaging-api:3.4.6
        +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-profile-api:3.4.6
        +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-storage-api:3.4.6
        +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-security-impl:3.4.6
        +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-xmlsec-impl:3.4.6
        +-org.apache.santuario:xmlsec:2.0.10
          +-commons-codec:commons-codec:1.11
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-xmlsec-impl:3.4.6
        +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-soap-impl:3.4.6
        +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.apache.httpcomponents:httpclient:4.5.13
        +-commons-codec:commons-codec:1.11
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-commons-codec:commons-codec:1.10
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-commons-codec:commons-codec:1.14

[ERROR]
Dependency convergence error for com.fasterxml.woodstox:woodstox-core:5.0.3 paths to dependency are:
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-xmlsec-impl:3.4.6
        +-org.apache.santuario:xmlsec:2.0.10
          +-com.fasterxml.woodstox:woodstox-core:5.0.3
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-com.fasterxml.woodstox:woodstox-core:5.3.0

[ERROR]
Dependency convergence error for org.bouncycastle:bcprov-jdk15on:1.59 paths to dependency are:
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-api:3.4.6
      +-org.opensaml:opensaml-xmlsec-api:3.4.6
        +-org.opensaml:opensaml-security-api:3.4.6
          +-org.bouncycastle:bcprov-jdk15on:1.59
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.opensaml:opensaml-xmlsec-impl:3.4.6
        +-org.cryptacular:cryptacular:1.1.4
          +-org.bouncycastle:bcprov-jdk15on:1.59
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.bouncycastle:bcprov-jdk15on:1.67

[ERROR]
Dependency convergence error for commons-collections:commons-collections:3.2.1 paths to dependency are:
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-org.opensaml:opensaml-saml-impl:3.4.6
      +-org.apache.velocity:velocity:1.7
        +-commons-collections:commons-collections:3.2.1
and
+-org.example:testing:1.0-SNAPSHOT
  +-com.coveo:saml-client:4.0.3
    +-commons-collections:commons-collections:3.2.2

Here's my pom.xml file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>testing</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.coveo</groupId>
            <artifactId>saml-client</artifactId>
            <version>4.0.3</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>1.0.1</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <configuration>
                            <rules>
                                <DependencyConvergence/>
                            </rules>
                        </configuration>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Login Successful on ADFS but there are some NameIDPolicyException on ADFS

I am able to login via ADFS and also successfully redirected to the desired page but on the ADFS Event Viewer there is an error-
Microsoft.IdentityServer.Protocols.Saml.InvalidNameIdPolicyException: MSIS7070: The SAML request contained a NameIDPolicy that was not satisfied by the issued token. Requested NameIDPolicy: AllowCreate: False Format: urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified SPNameQualifier: . Actual NameID properties: null. at Microsoft.IdentityServer.Web.Protocols.Saml.SamlProtocolManager.Issue(HttpSamlRequestMessage httpSamlRequestMessage, SecurityTokenElement onBehalfOf, String sessionState, String relayState, String& newSamlSession, String& samlpAuthenticationProvider, Boolean isUrlTranslationNeeded, WrappedHttpListenerContext context, Boolean isKmsiRequested) at Microsoft.IdentityServer.Web.Protocols.Saml.SamlProtocolHandler.RequestBearerToken(WrappedHttpListenerContext context, HttpSamlRequestMessage httpSamlRequest, SecurityTokenElement onBehalfOf, String relyingPartyIdentifier, Boolean isKmsiRequested, Boolean isApplicationProxyTokenRequired, String& samlpSessionState, String& samlpAuthenticationProvider) at Microsoft.IdentityServer.Web.Protocols.Saml.SamlProtocolHandler.BuildSignInResponseCoreWithSerializedToken(HttpSamlRequestMessage httpSamlRequest, WrappedHttpListenerContext context, String relyingPartyIdentifier, SecurityTokenElement signOnTokenElement, Boolean isKmsiRequested, Boolean isApplicationProxyTokenRequired) at Microsoft.IdentityServer.Web.Protocols.Saml.SamlProtocolHandler.BuildSignInResponseCoreWithSecurityToken(SamlSignInContext context, SecurityToken securityToken, SecurityToken deviceSecurityToken) at Microsoft.IdentityServer.Web.Protocols.Saml.SamlProtocolHandler.Process(ProtocolContext context) at Microsoft.IdentityServer.Web.PassiveProtocolListener.ProcessProtocolRequest(ProtocolContext protocolContext, PassiveProtocolHandler protocolHandler) at Microsoft.IdentityServer.Web.PassiveProtocolListener.OnGetContext(WrappedHttpListenerContext context)

Also when I am trying to decode the response via SamlClient.decodeAndValidateSamlResponse() then it is failing while validateResponse(). This is the error while devoding the SAMLResponse-
Exception in thread "main" com.coveo.saml.SamlException: Invalid status code: urn:oasis:names:tc:SAML:2.0:status:Requester at com.coveo.saml.SamlClient.validateResponse(SamlClient.java:457) at com.coveo.saml.SamlClient.decodeAndValidateSamlResponse(SamlClient.java:284) at com.coveo.saml.Main.decodeAndValidateResponse(Main.java:41) at com.coveo.saml.Main.main(Main.java:48)
What other things I need to do?

decodeAndValidate: AssertionImpl cannot be cast to Response

Hello,
I'm having the following issues when trying to decodeAndValidateSamlResponse:

java.lang.ClassCastException: org.opensaml.saml2.core.impl.AssertionImpl cannot be cast to org.opensaml.saml2.core.Response

that occurs in the following part.

(Response) Configuration.getUnmarshallerFactory()
                  .getUnmarshaller(parser.getDocument().getDocumentElement())
                  .unmarshall(parser.getDocument().getDocumentElement());

Does anyone have any suggestions?

metadata reader

Hi

Should I close the Reader passed to SamlClient.fromMetadata ?

Thanks
Eric

Support for RetrievalMethod for encrypted assertions

Please see datb-com fork of this for a 3 line modification to decodeEncryptedAssertion() that uses SimpleRetrievalMethodEncryptedKeyResolver to add support where an IDP (in this case Liferay7.4) provides encrypted assertions and specifies the EncryptionKey outside of the EncryptedData, referenced using RetrievalMethod. There is already a pull request open from a previous change (and i'm not a github expert) so please contact me for further info.

2023-09-05_17-47-36

Destination URI in Logout Request

Hello.
I have seen that when the logout request is made, it does not contain the attribute "Destination". Is there any way to add it? The IdP gives me an error for that reason.
Thanks.

initMetadataResolver Exception

I have the following setup that works perfectly in my test cases;

        InputStream inputStream = ClassLoader.getSystemResourceAsStream("misc/idp_meta.xml");
        Reader metadata = new InputStreamReader(inputStream);

        // Create the client
        SamlClient client = SamlClient.fromMetadata(
                "https://...",
                "https://.../#/login",
                metadata,
                SamlClient.SamlIdpBinding.POST);

This works exactly as expected. However when I build the project using maven-shade-plugin and run the identical method I get the following error;

java.lang.NullPointerException: [org.opensaml.saml.metadata.resolver.impl.DOMMetadataResolver.initMetadataResolver(DOMMetadataResolver.java:68), org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver.doInitialize(AbstractMetadataResolver.java:287), net.shibboleth.utilities.java.support.component.AbstractInitializableComponent.initialize(AbstractInitializableComponent.java:61), com.coveo.saml.SamlClient.createMetadataResolver(SamlClient.java:574), com.coveo.saml.SamlClient.fromMetadata(SamlClient.java:390), com.coveo.saml.SamlClient.fromMetadata(SamlClient.java:362)

Any ideas on why this might be happening?

Redirect binding requires compression

In Redirect binding, SAML Request should be compressed and then base64-encoded. But the current (1.5.0) code doesn't compress. That makes some IDPs (OpenAM) unhappy.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.