Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Commit 530248a

Browse files
authored
Merge pull request #3 from DSorlov/dev
Dev to Master v0.0.1
2 parents b37ea87 + a95fcf5 commit 530248a

21 files changed

+1183
-159
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Changelog for eid-provider-net
2+
3+
The format is based on [Keep a Changelog][keep-a-changelog]
4+
<!-- and this project adheres to [Semantic Versioning][semantic-versioning]. -->
5+
6+
## [Unreleased]
7+
- Nothing right now
8+
9+
## [0.0.1] (2020-09-12)
10+
11+
### Library
12+
- Initial release
13+
- Support for bankid, frejaeid and frejaorgid
14+
15+
### Powershell
16+
- Initial release
17+
- Support for bankid, frejaeid and frejaorgid
18+
19+
[keep-a-changelog]: http://keepachangelog.com/en/1.0.0/
20+
[Unreleased]: https://github.com/DSorlov/eid-provider-net/compare/master...dev
21+
[0.0.1]: https://github.com/DSorlov/eid-provider-net/releases/tag/v0.0.1

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@
55
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://img.shields.io/github/license/DSorlov/eid-provider)
66

77
# eid-provider-net
8-
This module is developed to enable rapid deployment of identity based authentication for .NET by creating a common interface to most of the suppliers for official electronic identification and it allows you to mix and match your suppliers. This is a .NET port from code that I have contributed in [eid-provider](https://github.com/DSorlov/eid-provider) and that is used in multiple projects. Documentation will be updated closer to release.
9-
10-
| :warning: This library is not relased yet for production and lacking documentation! |
11-
|----------------------------------------------------------|
8+
This code is developed to enable rapid deployment of identity based authentication for .NET by creating a common interface to most of the suppliers for official electronic identification and it allows you to mix and match your suppliers. This is a .NET port from code that I have contributed in [eid-provider](https://github.com/DSorlov/eid-provider) and that is used in multiple projects.
129

1310
| :warning: This library requires .NET 5.0 to run! |
1411
|----------------------------------------------------------|
1512

16-
The code in this repo consists of two projects (binary releases will be available once I get a bit further into the project). The first is the C# library that is performing all the operations towards the modules as outlined below and the other is a powershell cmdlet project that provides a module for use with PowerShell to make sure simple admin devops easily can be used to interact with the library.
13+
### eid-provider-net library
14+
A .net library that is performing all the operations towards the modules as outlined in the table below and the working horse of this project.
15+
See the [basic method documentation](docs/methods.md) or the [basic examples](docs/examples.md).
16+
17+
### eid-provider-net powershell module
18+
A powershell cmdlet project that provides a module for use with PowerShell to make sure simple admin devops easily can be used to interact with the library in scripts and wherever else it is needed, makes output more powershell friendly and is allaround a bit nicer to work with for interactive or scripting purposes.
19+
See [powershell examples](docs/powershell_examples.md).
1720

18-
There are basically right now two main types of integrations: one is working directly with the service apis and the other kind is working with a broker service. The broker services can be usefull if you have many integrations or other sources in your enterprise and you wish to use the same sources for these. Right now I am working on moving over and adapting the code for the providers for [eid-provider](https://github.com/DSorlov/eid-provider) and these will all be availiable before first stable release.
21+
### Supported integrations
22+
There are basically right now two main types of integrations: one is working directly with the service apis and the other kind is working with a broker service. The broker services can be usefull if you have many integrations or other sources in your enterprise and you wish to use the same sources for these. Right now I am working on moving over and adapting the code for the providers for [eid-provider](https://github.com/DSorlov/eid-provider) and will be added as they are needed and updated, submit an issue if you need to get one of them prioritized.
1923

2024
| ID-Type | Module | Vendor | Authentication | Signing | Geographies | Readiness |
2125
| --- | --- | --- | --- | --- | --- | --- |
2226
| BankID | [bankid](docs/bankid.md) | BankID | :heavy_check_mark: | :heavy_check_mark: | :sweden: | Production |
23-
| Freja eID | [frejaeid](docs/frejaeid.md) | BankID | :heavy_check_mark: | :heavy_check_mark: | :sweden: | Production |
27+
| Freja eID and Freja Org ID | [frejaeid](docs/frejaeid.md) | Freja eID | :heavy_check_mark: | :heavy_check_mark: | :sweden: | Production |
2428

2529

docs/bankid.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## BankID (bankid)
2+
3+
### Description
4+
This module works directly with the BankID api.
5+
It is supplied with working testing credentials and basic production details.
6+
7+
### Inputs and outputs
8+
9+
**Extra fields on completion**
10+
* `autostart_token` the token used for autostart
11+
* `autostart_url` code for invoking authorization
12+
13+
### Default Configuration
14+
>**Default production configuration (settings.production)**
15+
```
16+
endpoint: 'https://appapi2.bankid.com/rp/v5',
17+
client_cert: '',
18+
ca_cert: 'builtin://certs/bankid_prod.ca',
19+
allowFingerprint: true,
20+
password: ''
21+
```
22+
>**Default testing configuration (settings.testing)**
23+
```
24+
endpoint: 'https://appapi2.test.bankid.com/rp/v5',
25+
client_cert: 'builtin://certs/bankid_test.pfx',
26+
ca_cert: 'builtin://certs/bankid_test.ca',
27+
allowFingerprint: true,
28+
password: 'qwerty123'
29+
```

docs/examples.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Examples
2+
3+
Very simple examples. All methods are available in Async versions also and supporting IProgress for long running operations.
4+
5+
### Simple C# example for frejaeid
6+
This is a very simple example of calling authentication via frejaeid for the ssn 200101011212 and when final results are in dump them out on the console.
7+
```csharp
8+
EIDClientInitializationData config = new frejaeid.InitializationData(EIDEnvironment.Testing);
9+
EIDClient client = new frejaeid.Client((frejaeid.InitializationData)config);
10+
EIDResult = client.AuthRequest("200101011212");
11+
Console.WriteLine(EIDResult.ToString());
12+
```
13+
14+
### Simple C# example for bankid
15+
This is a very simple example of calling authentication via bankid for the ssn 200101011212 and when final results are in dump them out on the console.
16+
```csharp
17+
EIDClientInitializationData config = new bankid.InitializationData(EIDEnvironment.Testing);
18+
EIDClient client = new bankid.Client((bankid.InitializationData)config);
19+
EIDResult = client.AuthRequest("200101011212");
20+
Console.WriteLine(EIDResult.ToString());
21+
```
22+
23+
### Simple C# example for frejaeid with event callback
24+
This is a very simple example of calling authentication via frejaeid for the ssn 200101011212 and when final results are in dump them out on the console and also listen to events while it is processing
25+
```csharp
26+
EIDClientInitializationData config = new frejaeid.InitializationData(EIDEnvironment.Testing);
27+
EIDClient client = new frejaeid.Client((frejaeid.InitializationData)config);
28+
29+
//Attach a event listener
30+
client.RequestEvent = (e) => { Console.WriteLine(e.EIDResult.ToString(); };
31+
32+
EIDResult = client.AuthRequest("200101011212");
33+
Console.WriteLine(EIDResult.ToString());
34+
```
35+
36+
### Simple C# example configuring options in config
37+
This is a very simple example of calling authentication via frejaeid for the ssn 200101011212 and when final results are in dump them out on the console.
38+
```csharp
39+
EIDClientInitializationData config = new bankid.InitializationData(EIDEnvironment.Testing);
40+
config["client_cert"] = YourX509Certificate2();
41+
42+
EIDClient client = new bankid.Client((bankid.InitializationData)config);
43+
EIDResult = client.AuthRequest("200101011212");
44+
Console.WriteLine(EIDResult.ToString());
45+
```
46+

docs/frejaeid.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## Freja eID (frejaeid)
2+
3+
### Description
4+
This module works directly with the Freja eID REST API and Freja eID Org ID REST API.
5+
It is supplied with working testing credentials and basic production details.
6+
7+
This module exposes extra functions also (and async variants also):
8+
- **AddOrgIdRequest(string id, string title, string attribute, string value)** Creates a new orgidadd and returns after result is received
9+
- **InitAddOrgIdRequest(string id, string title, string attribute, string value)** Initiates orgidadd and returns a initialization object
10+
- **PollAddOrgIdResult(string id)** Checks the status of a orgidadd operation
11+
- **CancelAddOrgIdRequest(string id)** Cancels a pending orgidadd
12+
- **DeleteOrgId(string id)** Removes a orgid from an existing eid
13+
- **CreateCustomIdentifier(string id, string customid)** Creates a custom identifier for a specific eid
14+
- **DeleteCustomIdentifier(string customid)** Removes a custom identifier for a specific eid
15+
16+
### Inputs and outputs
17+
18+
**Extra fields on completion**
19+
* `autostart_token` the token used for autostart
20+
* `autostart_url` code for invoking authorization
21+
22+
### Default Configuration
23+
attribute_list is a comma separated list of EMAIL_ADDRESS,RELYING_PARTY_USER_ID,BASIC_USER_INFO,SSN,ADDRESSES,DATE_OF_BIRTH,ALL_EMAIL_ADDRESSES
24+
minimum_level is one of BASIC,EXTENDED,PLUS
25+
id_type is one of SSN,EMAIL,PHONE
26+
>**Default production configuration (settings.production)**
27+
```
28+
endpoint: 'https://services.prod.frejaeid.com',
29+
client_cert: '',
30+
ca_cert: 'builtin://certs/frejaeid_prod.ca',
31+
jwt_cert: {
32+
'aRw9OLn2BhM7hxoc458cIXHfezw': 'builtin://certs/frejaeid_prod_aRw9OLn2BhM7hxoc458cIXHfezw.jwt'),
33+
'onjnxVgI3oUzWQMLciD7sQZ4mqM': 'builtin://certs/frejaeid_prod_onjnxVgI3oUzWQMLciD7sQZ4mqM.jwt')
34+
},
35+
minimum_level: 'EXTENDED',
36+
password: '',
37+
default_country: 'SE',
38+
id_type: 'SSN',
39+
attribute_list: 'EMAIL_ADDRESS,RELYING_PARTY_USER_ID,BASIC_USER_INFO'
40+
```
41+
>**Default testing configuration (settings.testing)**
42+
```
43+
endpoint: 'https://services.test.frejaeid.com',
44+
client_cert: 'builtin://certs/frejaeid_test.ca',
45+
ca_cert: 'builtin://certs/frejaeid_test.pfx',
46+
jwt_cert: {
47+
'2LQIrINOzwWAVDhoYybqUcXXmVs': 'builtin://certs/frejaeid_test_2LQIrINOzwWAVDhoYybqUcXXmVs.jwt'),
48+
'HwMHK_gb3_iuNF1advMtlG0-fUs': 'builtin://certs/frejaeid_test_HwMHK_gb3_iuNF1advMtlG0-fUs.jwt')
49+
},
50+
minimum_evel: 'EXTENDED',
51+
password: 'test',
52+
default_country: 'SE',
53+
id_type: 'SSN',
54+
attribute_list: 'EMAIL_ADDRESS,RELYING_PARTY_USER_ID,BASIC_USER_INFO'
55+
```

docs/methods.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
## Methods
2+
3+
This is the general description of the methods availiable to you.
4+
I'm still struggling a bit to make this really readable in a good way, so perhaps easier to check with the [examples](examples.md).
5+
This as close a replication of the original library as possible, it is using language specific features and sports some nice taskbased interfaces.
6+
7+
### constructor(initialization data)
8+
9+
Configures the module according to the object sent in.
10+
Example configs can be obtained by accessing the `settings` properties of each module.
11+
12+
>**Inputs**
13+
14+
object(mandatory): A object containing configuration.
15+
16+
>**Outputs**
17+
18+
None
19+
20+
### PollAuthStatus(string) or PollSignStatus(string)
21+
22+
>**Inputs**
23+
24+
string(mandatory): A string containing the id of the authentication or signing you wish to check
25+
26+
>**Outputs**
27+
28+
A status object as one of the below:
29+
30+
```javascript
31+
{
32+
status: 'error' or 'pending',
33+
code: string,
34+
description: string,
35+
[details: string]
36+
}
37+
```
38+
39+
The description field is a user friendly error message in english. The details is a optional field that if it exists contains more information about the error. More generic error types often have a details field.
40+
41+
| Status | Possible Codes |
42+
| --- | --- |
43+
| error | system_error<br/>request_id_invalid<br/>api_error<br/>expired_transaction<br/>cancelled_by_user<br/>cancelled_by_idp |
44+
| pending | pending_notdelivered<br/>pending_user_in_app<br/>pending_delivered |
45+
46+
```javascript
47+
{
48+
status: 'completed',
49+
user: {
50+
firstname: string,
51+
lastname: string,
52+
fullname: string,
53+
ssn: string
54+
},
55+
extra: {..}
56+
}
57+
```
58+
59+
When the status is completed extra information may be in the extra block depending on which module you are using.
60+
61+
### Task AuthRequest(string, ProcessIProgress<EIDResult>, CancellationToken) or Task SignRequest(string, string, ProcessIProgress<EIDResult>, CancellationToken)
62+
63+
>**Inputs**
64+
65+
string: this is the ssn most probably put could be a object with special properties for that module.
66+
ProcessIProgress<EIDResult>: A ProcessIProgress to report back events and updates as they unfold
67+
CancellationToken: Standard CancellationToken to cancel the running task
68+
69+
>**Outputs**
70+
71+
Same as PollAuthStatus(string) or PollSignStatus(string) but wrapped in a awaitable Task
72+
73+
### InitAuthRequest(string) or InitSignRequest(string,string)
74+
75+
>**Inputs**
76+
77+
string(mandatory): this is the ssn most probably put could be a object with special properties for that module.
78+
string(only for signing): this is the text most probably put could be a object with special properties for that module.
79+
80+
>**Outputs**
81+
82+
A status object as one of the below:
83+
84+
```javascript
85+
{
86+
status: 'error',
87+
code: string,
88+
description: string,
89+
[details: string]
90+
}
91+
```
92+
93+
The description field is a user friendly error message in english. The details is a optional field that if it exists contains more information about the error. More generic error types often have a details field.
94+
95+
| Status | Possible Codes |
96+
| --- | --- |
97+
| error | system_error<br/>already_in_progress<br/>request_ssn_invalid<br/>request_text_invalid<br/>api_error |
98+
99+
```javascript
100+
{
101+
status: 'initialized',
102+
id: string,
103+
description: string,
104+
extra: {..}
105+
}
106+
```
107+
108+
When the status is completed extra information may be in the extra block depending on which module you are using.
109+
110+
### CancelAuthRequest(string) or CancelSignRequest(string)
111+
112+
>**Inputs**
113+
114+
string(mandatory): A string containing the id of the authentication or signing you wish to cancel
115+
116+
>**Outputs**
117+
118+
```javascript
119+
{
120+
status: 'cancelled',
121+
id: string,
122+
description: string,
123+
extra: {..}
124+
}

docs/powershell_examples.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Powershell Examples
2+
3+
Very simple examples.
4+
5+
### Simple power example for frejaeid
6+
This is a very simple example of calling authentication via frejaeid for the ssn 200101011212 and print the results console.
7+
8+
```powershell
9+
$config = Get-EIDConfig frejaeid -Enviroment Testing
10+
Request-EIDOperation $config -Type auth -Id 200101011212 -Wait
11+
```
12+
13+
### Simple powershell example for bankid
14+
This is a very simple example of calling authentication via frejaeid for the ssn 200101011212 and print the results console.
15+
16+
```powershell
17+
$config = Get-EIDConfig bankid -Enviroment Testing
18+
Request-EIDOperation $config -Type auth -Id 200101011212 -Wait
19+
```
20+
21+
### Add an organizational id to a existing eid via freja eid orgid
22+
This is a very simple example of calling authentication via frejaeid for the ssn 200101011212 and print the results console.
23+
24+
```powershell
25+
$config = Get-EIDConfig frejaeid -Enviroment Testing
26+
Start-EIDRequest $s -Type orgid -Id 200101011212 -Title "Corp Id" -Attribute "Employee #" -Value "123456" -Wait
27+
```

eid-provider-library/EIDClientEvent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace com.sorlov.eidprovider
88
{
99
public class EIDClientEvent : EventArgs
1010
{
11-
public EIDResult Result
11+
public EIDResult EIDResult
1212
{
1313
get => result;
1414
}

eid-provider-library/EIDResult.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public enum ResultStatus
1313
initialized,
1414
completed,
1515
pending,
16-
cancelled
16+
cancelled,
17+
ok
1718
}
1819

1920
public ResultStatus Status
@@ -69,6 +70,22 @@ internal static EIDResult CreateErrorResult(string code, string description)
6970
return new EIDResult(ResultStatus.error, data);
7071
}
7172

73+
internal static EIDResult CreateOKResult(string code, string description)
74+
{
75+
JObject data = new JObject();
76+
data["code"] = code;
77+
data["description"] = description;
78+
return new EIDResult(ResultStatus.ok, data);
79+
}
80+
internal static EIDResult CreateOKResult(string code, string description, JObject extra)
81+
{
82+
JObject data = new JObject();
83+
data["code"] = code;
84+
data["description"] = description;
85+
data["extra"] = extra;
86+
return new EIDResult(ResultStatus.ok, data);
87+
}
88+
7289
internal static EIDResult CreatePendingResult(string code, string description)
7390
{
7491
JObject data = new JObject();

0 commit comments

Comments
 (0)