Giter Club home page Giter Club logo

pravega-keycloak's Introduction

Pravega Build Status codecov License Version CII Best Practices

Pravega is an open source distributed storage service implementing Streams. It offers Stream as the main primitive for the foundation of reliable storage systems: a high-performance, durable, elastic, and unlimited append-only byte stream with strict ordering and consistency.

To learn more about Pravega, visit https://pravega.io

Prerequisites

  • Java 11+

In spite of the requirements of using JDK 11+ to build this project, client artifacts (and its dependencies) must be compatible with a Java 8 runtime. All other components are built and ran using JDK11+.

The clientJavaVersion project property determines the version used to build the client (defaults to 8).

Building Pravega

Checkout the source code:

git clone https://github.com/pravega/pravega.git
cd pravega

Build the pravega distribution:

./gradlew distribution

Install pravega jar files into the local maven repository. This is handy for running the pravega-samples locally against a custom version of pravega.

./gradlew install

Running unit tests:

./gradlew test

Setting up your IDE

Pravega uses Project Lombok so you should ensure you have your IDE setup with the required plugins. Using IntelliJ is recommended.

To import the source into IntelliJ:

  1. Import the project directory into IntelliJ IDE. It will automatically detect the gradle project and import things correctly.
  2. Enable Annotation Processing by going to Build, Execution, Deployment -> Compiler > Annotation Processors and checking 'Enable annotation processing'.
  3. Install the Lombok Plugin. This can be found in Preferences -> Plugins. Restart your IDE.
  4. Pravega should now compile properly.

For eclipse, you can generate eclipse project files by running ./gradlew eclipse.

Note: Some unit tests will create (and delete) a significant amount of files. For improved performance on Windows machines, be sure to add the appropriate 'Microsoft Defender' exclusion.

Releases

The latest pravega releases can be found on the Github Release project page.

Snapshot artifacts

All snapshot artifacts from master and release branches are available in GitHub Packages Registry

Add the following to your repositories list and import dependencies as usual.

maven {
    url "https://maven.pkg.github.com/pravega/pravega"
    credentials {
        username = "pravega-public"
        password = "\u0067\u0068\u0070\u005F\u0048\u0034\u0046\u0079\u0047\u005A\u0031\u006B\u0056\u0030\u0051\u0070\u006B\u0079\u0058\u006D\u0035\u0063\u0034\u0055\u0033\u006E\u0032\u0065\u0078\u0039\u0032\u0046\u006E\u0071\u0033\u0053\u0046\u0076\u005A\u0049"
    }
}

Note GitHub Packages requires authentication to download packages thus credentials above are required. Use the provided password as is, please do not decode it.

If you need a dedicated token to use in your repository (and GitHub Actions) please reach out to us.

As alternative option you can use JitPack (https://jitpack.io/#pravega/pravega) to get pre-release artifacts.

Quick Start

Read Getting Started page for more information, and also visit sample-apps repo for more applications.

Running Pravega

Pravega can be installed locally or in a distributed environment. The installation and deployment of pravega is covered in the Running Pravega guide.

Support

Don’t hesitate to ask! Contact the developers and community on slack (signup) if you need any help. Open an issue if you found a bug on Github Issues.

Documentation

The Pravega documentation is hosted on the website: https://pravega.io/docs/latest or in the documentation directory of the source code.

Contributing

Become one of the contributors! We thrive to build a welcoming and open community for anyone who wants to use the system or contribute to it. Here we describe how to contribute to Pravega! You can see the roadmap document here.

About

Pravega is 100% open source and community-driven. All components are available under Apache 2 License on GitHub.

pravega-keycloak's People

Contributors

addprs avatar apoorva918 avatar crazyzhou avatar derekm avatar divyank-lakhera avatar eronwright avatar raulgracia avatar sabuz-262 avatar sarlaccpit avatar yaol7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

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

pravega-keycloak's Issues

Connection problems to Keycloak should be retried

Problem description

The Keycloak client that is used to obtain access tokens and relying party tokens (RPTs) can run into connection problems making these REST requests to Keycloak. When this happens, the Pravega client which uses this implementation of the Credentials interface does not get a chance to retry the attempts to retrieve a token since it doesn't know what the cause (straight authentication errors should not be retried while other http errors should)

Expected behavior

If Keycloak is unreachable when a token request is sent, the request should be retried a certain number of times. After the number of retries is exceeded can the exception actually be bubbled up to the Credentials.getAuthenticationToken() call.

Update buildVersion in master to 0.12.0-SNAPSHOT

Problem description
As part of 0.11.0 release, we need to update the build version in master.

Problem location
Gradle properties.

Suggestions for an improvement
Update the Pravega version and set Pravega Keycloak version to 0.12.0-SNAPSHOT.

Guava used without specifying direct dependency

This line is introduced in this commit: 6f44fb5, and this guava dependency is from the pravega-shared-security which is a compileOnly dependency in keycloak client. This means application needs to have guava in the classpath, but unfortunately Flink connector has shaded guava to avoid conflict
https://github.com/pravega/flink-connectors/blob/53666981e3d42a4de7a28686f562a18d69410620/build.gradle#L156

This makes me have java.lang.ClassNotFoundException: com.google.common.base.Strings when I try to upgrade the keycloak client and run the Flink jobs. Although this could be fixed by the application to explicitly add guava, but I think it's better to fix in this project.

Update buildVersion in master to 0.10.0-SNAPSHOT

Problem description
As part of 0.9.0 release, we need to update the build version in master.

Problem location
Gradle properties.

Suggestions for an improvement
Update the buildVersion to 0.10.0-SNAPSHOT.
Update the pravegaVersion to 0.9.0

Upgrade Pravega Keycloak Client: 21

Problem description:
Need an update for keycloak client dependency to version 21.1.2 to support Keycloak 21.

Update location:
Gradle.properties file and new API in Keycloak 21.

Wrong count number of the artifact

Problem description

A typical name of the artifact should be something like 0.10.0-1.ff9f6d1-SNAPSHOT. With the [version]-[commit count]-[commit sha]-SNAPSHOT format. But for artifacts produced by Github Actions, the commit count are always set to 1 now. This is caused by the depth==1 clone by default.

ref: First bullet point in https://github.com/marketplace/actions/checkout#whats-new

Problem location

./.github/workflows/build.yml

Suggestions for an improvement

Fetch all the commits not only the HEAD from the repo.
you can refer to the Flink connector PR: pravega/flink-connectors#492

Prepare r0.9 branch for release of 0.9.0

Problem description

Update Pravega dependency version in branch r0.9 and update the release version.

Problem location
gradle.properties

Suggestions for an improvement
Update pravegaVersion to 0.9.0 and buildVersion to 0.9.0

Travis CI builds fails to push snapshots to JFrog due to bad credentials

Problem description
Travis CI builds are unable to publish snapshots to JFrog, due to bad credentials.

The code referenced in the Problem Location throws this error:

* What went wrong:
Execution failed for task ':client:publishMavenJavaPublicationToJcenterSnapshotRepository'.
> Failed to publish publication 'mavenJava' to repository 'jcenterSnapshot'
   > Could not PUT 'https://oss.jfrog.org/oss-snapshot-local/io/pravega/pravega-keycloak-client/0.8.0-32.ac17464-SNAPSHOT/maven-metadata.xml'. Received status code 401 from server: 

Problem location

- secure: "aU2lXO9NWMgU1LkQlzcJPs9j2WgaE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L2kg9uvZiJsousCoKIdCjjhWZyVBmEr5zWp1ThjZW6HoSWqEUs39FMuriEEcnVtEqpLQxGbB1uaDRcVTvCi3lZJNWMA8RCJoFTZ7KCtVBUnuMPhJ3C/EDNVcpwM8QKSFaXv2g37na0kOlQiM9OG/LFyErqVJvpn9YuAlsF4ecGjZrGcVDLnOh2N+NFeNsKyTtFcKKTFaVpDLh5E9A6Ei9gIkUTtU3eECRNPJ2tnpu0UHKqSCnM38DLHEzw1+DCao="

Suggestions for an improvement
Update credentials to a new set.

KeycloakAuthzClient should have a reasonable default upper limit wait time for exponential backoff

In KeycloakAuthzClient, the default try policy for http error is max 20 times, for 1st attempt wait 100ms, for following attempts double wait time of previous one.
With this setting at 20th attempt client will wait 2^19 *100 ms = 14.56h before retrying.

We've got a system once had a DNS issue to keycloak server. When the DNS issue was resolved, the client was stuck at19th retry. And client could not recover without waiting another 7 hours.

It is true that KeycloakAuthzClientBuild has offered method to override default http retry configs, but the option is not viable to be configured via EventStreamClientFactory via PravegaKeycloakCredentials.

There should be a reasonable default upper limit wait time set in KeycloakAuthzClient itself to limit it to minutes maximum.

Develop a client-side plugin

Develop a plugin for Pravega client to authenticate with Keycloak.

  1. Load a Keycloak adapter config
  2. Authenticate with Keycloak to obtain an initial access token
  3. Obtain an authorization token for the Pravega resource server

Prepare r0.10 branch for release

Problem description

Update Pravega dependency version in branch r0.10 to take in pravega interfaces from Pravega 0.10.1
Update this build Version to 0.10.1

Problem location

gradle.properties

Keycloak client 23.0.4 upgrade changes

Problem description:
Need an update for Keycloak client dependency to version 23.0.4 to support Keycloak 23.

Update location:
gradle.properties
gradle/wrapper/gradle-wrapper.properties
build.gradle

Move master branch to 0.11.0-SNAPSHOT

Problem description

Update Pravega dependency version in master branch to take in pravega interfaces from Pravega 0.10.1
Update this build Version to 0.11.0-SNAPSHOT

Problem location

gradle.properties

Prepare r0.8 branch for release of 0.8.0

Problem description
Update Pravega dependency version in branch r0.8 and update the release version.

Problem location
gradle.properties

Suggestions for an improvement

Prepare r0.11 branch for release of 0.11.0

Problem description
Update Pravega dependency version in branch r0.11 and update the release version.

Problem location
gradle.properties

Suggestions for an improvement

Add support for GitHub action and snapshots to GH packages

Overview

We need to migrate to using GitHub actions for regular builds to be inline with the rest of Pravega components.

Additionally, we need to publish snapshots to GitHub packages instead of JCenter.

Regular releases will still be published to Maven Central as usual.

Where

Need to add a github workflow and remove travis ci yaml file.

Update Keycloak client libraries to 10.0.2 for pravega keycloak credentials plugin

Task: The PravegaKeycloakCredentials library uses Keycloak 6.0.1 AuthzClient.
As part of keycloak-10 upgrade needs to be updated using 10.0.2 libraries and retested.
Testing:
This can be tested updating the libraries pravega-keycloak libraries, once Issue#12 is fixed

After the Jar is created with the updated libraries test with Keycloak 10 server and verify if client receives tokens.

Update master build version to 0.13.0-SNAPSHOT

Problem description
As part of 0.12.0 release, we need to update the build version in master.

Problem location
Gradle properties.

Suggestions for an improvement
Update the Pravega version and set Pravega Keycloak version to 0.13.0-SNAPSHOT.

UnknownHostException should be retried

Problem

A previous PR had brought some robustness changes whereby if the requests to Keycloak responded with certain exceptions, the request would be retried, while others would result in a fatal/terminal state.

A particular exception was not added to the list of explicitly retried situations: "java.net.UnknownHostException".

This should ideally be retried since there are situations where network problems (DNS) occur and name resolution temporarily fails.

Solution

Catch java.net.UnknownHostException here

Release process does not follow the standardized process that other Pravega repos follow

This repo repository has not been doing releases in a way that is aligned with other Pravega repos like Pravega and Pravega Flink Connector. It uses a release process which is very different from how rest of the Pravega repos do. Among other things:

  1. Unlike other related projects, it does not publish its releases to Maven Central. It pushes the releases to JFrog Artifactory. Users obtain other Pravega binaries from Maven Central, and they'd expect to find this one there too.
  2. To add to the woes, there was a version of this repo's binaries that was published to Maven central (https://mvnrepository.com/artifact/io.pravega/pravega-keycloak-client), but it is an old one (v0.6.0.1). So, users may be fooled into believing that's the latest one.
  3. Binary publishing is automated, which can be risky at times. Like other Pravega projects, releases should be staged so that the appropriate tests can be performed to ensure the build is good.

Update buildVersion in master to 0.9.0-SNAPSHOT

Problem description
As part of 0.8.0 release, we need to update the build version in master.

Problem location
Gradle properties.

Suggestions for an improvement
Update the Pravega version to 0.9.0-SNAPSHOT.

Travis CI fails to push snapshots to JFrog due to wrong credentials

Problem description
Travis CI builds are unable to publish snapshots to JFrog, due to bad credentials.

The code referenced in the Problem Location throws this error:

Could not PUT 'https://oss.jfrog.org/oss-snapshot-local/io/pravega/pravega-keycloak-client/0.8.0-16.ef203a4-SNAPSHOT/maven-metadata.xml'. Received status code 401 from server:

Problem location

script: ./gradlew publish -PpublishRepo=jcenterSnapshot -PpublishUsername=$BINTRAY_USER -PpublishPassword=$BINTRAY_KEY

Suggestions for an improvement
Update credentials to a new set.

The keycloak client does not retry enough on exceptions coming from Keycloak call

Overview

Network problems can occur anytime and manifest themselves through a variety of not always predictable exceptions types, and it's important to have resilience built-in when trying to reach Keycloak to obtain tokens.

There is such resilience built-in in the KeycloakAuthzClient.java: https://github.com/pravega/pravega-keycloak/blob/master/client/src/main/java/io/pravega/keycloak/client/KeycloakAuthzClient.java#L127 where we carefully decide which family of exceptions should be retried and which shouldn't.

The problem is we try too hard to guess which exact ones should be retryable and we which shouldn't, and we also take an approach of "if I don't know this exception, don't retry it". This means that from time to time, strange exceptions occur if in an SSL environment, which get wrapped into RuntimeExceptions, sometimes not etc. It makes it very hard to predict what can be retried and what can't.

One example of a new one that was observed recently:

ERROR [2021-08-26 20:49:22.164] [grpc-default-executor-138] i.p.k.client.KeycloakAuthzClient: Other non retryable exception
java.io.EOFException: SSL peer shut down incorrectly
	at sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:167)
	at sun.security.ssl.SSLTransport.decode(SSLTransport.java:109)
	at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1392)
	at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1300)

As well as: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake

Both of these should ideally be retried.

(note that other exceptions can also occur in non SSL environments)

Solution

Only use a very small set of exceptions that you know for sure should not be retried such as authentication errors. For anything else, let it be. It'll get retried for the max amount of retries configured. Most likely it was meant to be retried. If not, it'll just eventually fail.

Problem location

https://github.com/pravega/pravega-keycloak/blob/master/client/src/main/java/io/pravega/keycloak/client/KeycloakAuthzClient.java#L127

Solution

Zero out the few known exceptions we should not retry, and let everything else be retried by default.

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.