Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.0.0 #5

Merged
merged 60 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cb12586
Init project structure, added linting configuration
alexbalakirev May 31, 2024
d0a247c
Added generated client, dependencies and tweaked code formatters
alexbalakirev Jun 21, 2024
976522d
add simple ci
alexbalakirev Jun 28, 2024
0cc0588
test ci/build
alexbalakirev Jun 28, 2024
e5ae0cd
Update ci.yml
alexbalakirev Jun 28, 2024
78b00bb
Update ci.yml
alexbalakirev Jun 28, 2024
2766228
Update ci.yml
alexbalakirev Jun 28, 2024
2da3f9b
fix path compatibility in pom.xml
alexbalakirev Jun 28, 2024
811ba9f
fix java version in ci and path compatibilities
alexbalakirev Jun 28, 2024
b23fdac
add caching of maven dependencies to ci
alexbalakirev Jun 28, 2024
748a7c2
fixed path issues, make checkstyle maven integration and plugin runnable
alexbalakirev Jun 28, 2024
887301e
Implemented Config.java
alexbalakirev Jun 28, 2024
3b6b0a2
add .env and dotenv-java for environment variables management
alexbalakirev Jul 5, 2024
09d604d
add .env to gitignore
alexbalakirev Jul 5, 2024
dfe788f
fix checkstyle
alexbalakirev Jul 5, 2024
ee55af1
Added working user service, test for it,test utils, and minimal
alexbalakirev Jul 5, 2024
6bed96b
Migrated to lombrok, completed CorbadoServerException, Completed
alexbalakirev Jul 12, 2024
e932c90
change test phase in ci to verify
alexbalakirev Jul 12, 2024
0695e9a
Partially implemented SessionService/Test
alexbalakirev Jul 12, 2024
f3976d5
Implemented session service
alexbalakirev Aug 2, 2024
ff8c6dc
Migrated to v2 of backend api
alexbalakirev Aug 2, 2024
e390c75
Remove old v1 services
alexbalakirev Aug 9, 2024
97f80ba
Add log4j2 logging dependencies and configuration files
alexbalakirev Aug 9, 2024
3950b40
Expand UserService implementation, fix backendApi url
alexbalakirev Aug 9, 2024
bb87bf3
Add IdentifierService
alexbalakirev Aug 9, 2024
4ecaffa
Corrected Identifier search function by userID
alexbalakirev Aug 9, 2024
7d63249
updated generated code from new OpenAPI specification
alexbalakirev Aug 13, 2024
2c578a4
finished UserService implementation and tests (including new api
alexbalakirev Aug 13, 2024
d24b0b3
fix access modifiers
alexbalakirev Aug 13, 2024
a23fb40
Fixed session service in SDK, refactoring, added SDK version
alexbalakirev Aug 14, 2024
8b826ef
Update README
alexbalakirev Aug 14, 2024
c6a3b35
add README file extention
alexbalakirev Aug 14, 2024
32b211e
fix links in README.md
alexbalakirev Aug 14, 2024
6839c9f
Update README.md
alexbalakirev Aug 14, 2024
5ccf5a9
Create LICENSE
alexbalakirev Aug 16, 2024
895d02e
Reduced logging during test, added new functions for identifier service,
alexbalakirev Aug 16, 2024
718fae7
Merge branch 'development' of [email protected]:corbado/corbado-java.git…
alexbalakirev Aug 16, 2024
8c40633
Made test prefer actual environment variables over dotenv variables
alexbalakirev Aug 16, 2024
66ff09c
added gpg sign and publishing plugins
alexbalakirev Aug 16, 2024
a0e141a
added project information to pom.xml
alexbalakirev Aug 16, 2024
03281b6
Added spring boot example
alexbalakirev Aug 20, 2024
542ddf4
Update github actions for better resource usage
alexbalakirev Aug 20, 2024
54be88f
Add deployment stage on version tags for CI/CD
alexbalakirev Aug 20, 2024
047b91c
corrected backendApi setter, added delete() for users and identifiers,
alexbalakirev Aug 23, 2024
22087b2
Prepare for release 1.0.0
alexbalakirev Aug 27, 2024
17bc129
Fix sdk instantiation in Tests
alexbalakirev Aug 27, 2024
1a32c34
Added secrets to ci.yml
alexbalakirev Aug 28, 2024
87e1fae
Added gpg key configuration during build stage
alexbalakirev Aug 28, 2024
94230ad
change BACKEND_API to variable in gh actions
alexbalakirev Aug 28, 2024
61c275b
debug gpg key
alexbalakirev Aug 28, 2024
18af23b
Update pom.xml to verify with gpg only on install phase
alexbalakirev Aug 28, 2024
9682eb7
Update pom.xml to allow autopublish in publishing-plugin
alexbalakirev Aug 28, 2024
ed1db35
Prepare for release 1.0.1
alexbalakirev Aug 28, 2024
bfa7838
fix deployment job
alexbalakirev Aug 28, 2024
188b0a6
fix deployment job dependency
alexbalakirev Aug 28, 2024
e5c2958
Update ci.yml
alexbalakirev Aug 28, 2024
114c061
Update ci.yml
alexbalakirev Aug 28, 2024
e42aeb3
update ci.yml
alexbalakirev Aug 28, 2024
b7d9c30
Added settings.xml to ci.yml
alexbalakirev Aug 28, 2024
87c81bb
Update ci.yml
alexbalakirev Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CORBADO_API_SECRET=your_api_secret
CORBADO_PROJECT_ID=your_project_id
CORBADO_BACKEND_API=your_backend_api
160 changes: 160 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: CI

on:
workflow_dispatch: {}
push:
branches:
- master
- beta
- 'sdk-release/**'
- 'feature/**'
- development
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches:
- master
- beta
- 'sdk-release/**'
- 'feature/**'
- development

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: "17" # always use 17 LTS for building
distribution: zulu
architecture: x64

- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('**/src/**') }}
restore-keys: |
${{ runner.os }}-maven

- name: Configure GPG Key
run: |
echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}


- name: Install dependencies
run: mvn clean install -DskipTests

- name: Save Maven build artifacts
if: success()
uses: actions/upload-artifact@v3
with:
name: maven-artifacts
path: target/

test:
name: Test
runs-on: ubuntu-latest
needs: build # Ensure build job runs before this one

strategy:
fail-fast: false
matrix:
java-version: ["8", "11", "17", "18", "19", "20"]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: maven-artifacts

- name: Setup Test Java Runtime
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: zulu
architecture: x64

- name: Cache Maven dependencies for tests
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ matrix.java-version }}-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('**/src/**') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Run test suite
env:
CORBADO_API_SECRET: ${{ secrets.CORBADO_API_SECRET }}
CORBADO_PROJECT_ID: ${{ secrets.CORBADO_PROJECT_ID }}
CORBADO_BACKEND_API: ${{ vars.CORBADO_BACKEND_API }}
run: mvn --batch-mode --update-snapshots verify -DskipInstall

deploy:
name: Deploy to Maven Central
runs-on: ubuntu-latest
needs: [build,test]

if: startsWith(github.ref, 'refs/tags/v') # Only run on version tags
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: maven-artifacts

- name: Create Maven settings.xml
run: |
mkdir -p ~/.m2
echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/SETTINGS/1.0.0/settings.xsd">
<servers>
<server>
<id>central</id>
<username>${{ vars.OSSRH_USERNAME }}</username>
<password>${{ secrets.OSSRH_PASSWORD }}</password>
</server>
</servers>
</settings>' > ~/.m2/settings.xml
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: zulu
architecture: x64
server-id: central

- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('**/src/**') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Setup GPG for Signing
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --batch --import
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
gpg-connect-agent reloadagent /bye

- name: Deploy to Maven Central
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: mvn deploy -DskipTests -P release --settings ~/.m2/settings.xml

10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
s
/bin/
/target/
.project
.settings
.classpath
/corbado-java-cs-cleanup.xml
/corbado-java-cs-formatter.xml
/.checkstyle
.env
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Corbado GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 0 additions & 1 deletion README

This file was deleted.

116 changes: 116 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<img width="1070" alt="GitHub Repo Cover" src="https://github.com/corbado/corbado-php/assets/18458907/aa4f9df6-980b-4b24-bb2f-d71c0f480971">

# Corbado Java SDK

[![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
[![documentation](https://img.shields.io/badge/documentation-Corbado_Backend_API_Reference-blue.svg)](https://apireference.cloud.corbado.io/backendapi/)
[![Slack](https://img.shields.io/badge/slack-join%20chat-brightgreen.svg)](https://join.slack.com/t/corbado/shared_invite/zt-1b7867yz8-V~Xr~ngmSGbt7IA~g16ZsQ)

The [Corbado](https://www.corbado.com) Java SDK provides convenient access to the [Corbado Backend API](https://apireference.cloud.corbado.io/backendapi/) from applications written in the Java language.

:warning: The Corbado Java SDK is commonly referred to as a private client, specifically designed for usage within closed backend applications. This particular SDK should exclusively be utilized in such environments, as it is crucial to ensure that the API secret remains strictly confidential and is never shared.

:rocket: [Getting started](#rocket-getting-started) | :hammer_and_wrench: [Services](#hammer_and_wrench-services) | :books: [Advanced](#books-advanced) | :speech_balloon: [Support & Feedback](#speech_balloon-support--feedback)

## :rocket: Getting started

### Requirements

- Java 8 or later

### Installation

#### Gradle users

Add this dependency to your project's build file:

```groovy
implementation "com.corbado:corbado-java:1.0.1"
```

#### Maven users

Add this dependency to your project's POM:

```xml
<dependency>
<groupId>com.corbado</groupId>
<artifactId>corbado-java</artifactId>
<version>1.0.1</version>
</dependency>
```

### Usage

To create a Corbado Java SDK instance you need to provide your `Project ID` and `API secret` which can be found at the [Developer Panel](https://app.corbado.com).

```Java
final Config config = new Config(projectId, apiSecret);
CorbadoSdk sdk = new CorbadoSDK(config);
```

### Examples

A list of examples can be found in the integration tests [here](/src/test/java/com/corbado/integration/).

## :hammer_and_wrench: Services

The Corbado Java SDK provides the following services:

- `sessions` for managing sessions ([example spring boot application](https://github.com/corbado/example-passkeys-java-spring-boot))
- `users` for managing users ([examples](/src/test/java/com/corbado/integration/UserServiceIT.java))
- `identifiers` for managing identifiers ([examples](/src/test/java/com/corbado/integration/IdentifierServiceIT.java))

To use a specific service, such as `users`, invoke it as shown below:

```Java
UserService users = sdk.getUsers();
```

## :books: Advanced

### Error handling

The Corbado Java SDK throws exceptions for all errors. The following exceptions are thrown:

- `CorbadoServerException` for server errors (server side)
- `StandardException` for everything else (client side)

If the Backend API returns a HTTP status code other than 200, the Corbado Java SDK throws a `CorbadoServerException`. The `CorbadoServerException`class parses the server response to access all important data. One of the test cases:
```Java
UserService users = sdk.getUsers();
final UserEntity user = TestUtils.createUser();
users.delete(user.getUserID());
final CorbadoServerException e =
assertThrows(
CorbadoServerException.class,
() -> {
final UserEntity ret = users.get(user.getUserID());
});
assertNotNull(e);
assertEquals(400, e.getHttpStatusCode());
assertEquals("does not exist", e.getValidationMessages().get(0).getMessage());
assertEquals("userID", e.getValidationMessages().get(0).getField());
```
Take a look at the `CorbadoServerException` class, if you need get more information out of exception.


## :speech_balloon: Support & Feedback

### Report an issue

If you encounter any bugs or have suggestions, please [open an issue](https://github.com/corbado/corbado-java/issues/new).

### Slack channel

Join our Slack channel to discuss questions or ideas with the Corbado team and other developers.

[![Slack](https://img.shields.io/badge/slack-join%20chat-brightgreen.svg)](https://join.slack.com/t/corbado/shared_invite/zt-1b7867yz8-V~Xr~ngmSGbt7IA~g16ZsQ)

### Email

You can also reach out to us via email at [email protected].

### Vulnerability reporting

Please report suspected security vulnerabilities in private to [email protected]. Please do NOT create publicly viewable issues for suspected security vulnerabilities.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.1
Loading
Loading