-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from enclave-networks/develop
Release
- Loading branch information
Showing
25 changed files
with
324 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ on: | |
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -25,15 +24,15 @@ jobs: | |
- name: Determine Version | ||
id: gitversion | ||
uses: gittools/actions/gitversion/[email protected] | ||
|
||
- name: Setup .NET 6 (SDK) | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 6.0.x | ||
dotnet-version: 6.0.x | ||
source-url: https://nuget.pkg.github.com/enclave-networks/index.json | ||
env: | ||
NUGET_AUTH_TOKEN: ${{github.token}} | ||
|
||
- name: Build | ||
run: dotnet build Enclave.Sdk.Api.sln -c Release /p:Version=${{ steps.gitversion.outputs.SemVer }} | ||
|
||
|
@@ -42,10 +41,14 @@ jobs: | |
run: dotnet test -c Release | ||
|
||
- name: Push Github Source Packages | ||
if: github.event_name == 'push' | ||
run: dotnet nuget push src/**/*${{ steps.gitversion.outputs.SemVer }}.nupkg --api-key ${{github.token}} -s https://nuget.pkg.github.com/enclave-networks/index.json --skip-duplicate --no-symbols true | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/develop' | ||
run: dotnet nuget push src/**/*${{ steps.gitversion.outputs.SemVer }}.nupkg --api-key ${{github.token}} -s https://nuget.pkg.github.com/enclave-networks/index.json --skip-duplicate | ||
|
||
- name: Push To nuget.org | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
run: dotnet nuget push src/**/*${{ steps.gitversion.outputs.SemVer }}.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate | ||
|
||
- name: Create Release | ||
- name: Create Release | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
uses: actions/create-release@v1 | ||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
assembly-versioning-scheme: None | ||
mode: ContinuousDelivery | ||
next-version: 0.0.1 | ||
next-version: 1.0.0 | ||
branches: | ||
main: | ||
mode: ContinuousDelivery | ||
develop: | ||
increment: Patch | ||
increment: Patch | ||
ignore: | ||
sha: [] | ||
merge-message-formats: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Net.Http.Json; | ||
using Enclave.Sdk.Api.Clients.Interfaces; | ||
using Enclave.Sdk.Api.Data.Authority; | ||
|
||
namespace Enclave.Sdk.Api.Clients; | ||
|
||
/// <inheritdoc cref="IAuthorityClient" /> | ||
internal class AuthorityClient : ClientBase, IAuthorityClient | ||
{ | ||
/// <summary> | ||
/// Constructor which will be called by <see cref="EnclaveClient"/> when it's created. | ||
/// </summary> | ||
/// <param name="httpClient">an instance of httpClient with a baseURL referencing the API.</param> | ||
public AuthorityClient(HttpClient httpClient) | ||
: base(httpClient) | ||
{ | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<EnrolResult> EnrolAsync(EnrolRequest requestModel) | ||
{ | ||
if (requestModel is null) | ||
{ | ||
throw new ArgumentNullException(nameof(requestModel)); | ||
} | ||
|
||
var result = await HttpClient.PostAsJsonAsync($"authority/enrol", requestModel, Constants.JsonSerializerOptions); | ||
|
||
var model = await DeserialiseAsync<EnrolResult>(result.Content); | ||
|
||
EnsureNotNull(model); | ||
|
||
return model; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Enclave.Sdk.Api.Data.Authority; | ||
|
||
namespace Enclave.Sdk.Api.Clients.Interfaces; | ||
|
||
/// <summary> | ||
/// Provides operations enrol a new system. | ||
/// </summary> | ||
public interface IAuthorityClient | ||
{ | ||
/// <summary> | ||
/// Enrol a new system. | ||
/// </summary> | ||
/// <param name="requestModel">The Request model to enrol the system.</param> | ||
/// <returns>An EnrolResult model.</returns> | ||
Task<EnrolResult> EnrolAsync(EnrolRequest requestModel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace Enclave.Sdk.Api.Data.Authority; | ||
|
||
/// <summary> | ||
/// Defines bit-flags indicating what a certificate can be used for. | ||
/// </summary> | ||
[Flags] | ||
public enum CertificatePermittedUse : byte | ||
{ | ||
/// <summary> | ||
/// No Permitted Uses. | ||
/// </summary> | ||
None = 0x0, | ||
|
||
/// <summary> | ||
/// For individual endpoints. | ||
/// </summary> | ||
/// <remarks> | ||
/// Certificate commonName is assigned by the root or intermediate, the public key owners identity is not validated. | ||
/// Certificate may only be signed by an intermediate or root. issued to a primary key. | ||
/// Certificate may not be used to signed by another. Certificates signed by endpoints are considered invalid. | ||
/// </remarks> | ||
Endpoint = 0x2, | ||
|
||
/// <summary> | ||
/// Special class of endpoint certificate reserved for operational infrastructure, discovery service, relay services etc. | ||
/// </summary> | ||
Infrastructure = 0x4, | ||
|
||
/// <summary> | ||
/// For intermediate level certificates | ||
/// =================================== | ||
/// This class may only sign endpoints (class 0), and can only be signed by a root. | ||
/// </summary> | ||
Intermediate = 0x8, | ||
|
||
/// <summary> | ||
/// For root level certificates | ||
/// =========================== | ||
/// This class may only be used to sign intermediates and must be signed with own public key. | ||
/// </summary> | ||
Root = 0x10, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace Enclave.Sdk.Api.Data.Authority; | ||
|
||
/// <summary> | ||
/// Model for an enrolment request. | ||
/// </summary> | ||
public class EnrolRequest | ||
{ | ||
/// <summary> | ||
/// A 256-bit (32 byte) public key for signing, in base-64. | ||
/// </summary> | ||
public string PublicKey { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// An Enclave Enrolment Key. | ||
/// </summary> | ||
public string EnrolmentKey { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// A 256-bit (32 byte) nonce for the request, in base-64. | ||
/// </summary> | ||
public string Nonce { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// Unix epoch timestamp from which the certificate becomes valid. | ||
/// If none provided, defaults to now. | ||
/// </summary> | ||
public long? NotBefore { get; set; } | ||
|
||
/// <summary> | ||
/// Unix epoch timestamp until which the certificate is valid. If none provided, defaults to a permanent certificate. | ||
/// </summary> | ||
public long? NotAfter { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
namespace Enclave.Sdk.Api.Data.Authority; | ||
|
||
/// <summary> | ||
/// Defines the response model for an issued certificate. | ||
/// </summary> | ||
public class EnrolResult | ||
{ | ||
/// <summary> | ||
/// The version number field denotes the version of the certificate. | ||
/// </summary> | ||
public int Version { get; init; } | ||
|
||
/// <summary> | ||
/// The unique serial number of the certificate assigned by the certification authority; the size of the serial number field is a 16 byte (128 bit) guid. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para>The value is unique to every certificate issued by a certification authority so as to allow identification of individual certificates.</para> | ||
/// <para>The value may be randomly selected, or incremented by the certificate authority.</para> | ||
/// </remarks> | ||
public byte[] SerialNumber { get; init; } = default!; | ||
|
||
/// <summary> | ||
/// Permitted uses of the certificate. | ||
/// </summary> | ||
public CertificatePermittedUse PermittedUse { get; init; } | ||
|
||
/// <summary> | ||
/// Unique system name assigned to the generated certificate. Used to identify the system in the rest of Enclave. | ||
/// </summary> | ||
public string SubjectDistinguishedName { get; init; } = default!; | ||
|
||
/// <summary> | ||
/// Contains the provided public key. | ||
/// </summary> | ||
public byte[] SubjectPublicKey { get; init; } = default!; | ||
|
||
/// <summary> | ||
/// Unix epoch timestamp indicating the point from which this certificate is considered valid. | ||
/// </summary> | ||
public long NotBefore { get; init; } | ||
|
||
/// <summary> | ||
/// Unix epoch timestamp indicating the point after which this certificate is no longer considered valid. | ||
/// </summary> | ||
public long NotAfter { get; init; } | ||
|
||
/// <summary> | ||
/// The name of the issuing authority. | ||
/// </summary> | ||
public string IssuerDistinguishedName { get; init; } = default!; | ||
|
||
/// <summary> | ||
/// The public key of the issuing authority. | ||
/// </summary> | ||
public byte[] IssuerPublicKey { get; init; } = default!; | ||
|
||
/// <summary> | ||
/// Signature of this certificate. | ||
/// </summary> | ||
public byte[] Signature { get; init; } = default!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.