@@ -6,90 +6,104 @@ invoking our Conjur API to perform operations on stored data (add, retrieve, etc
66
77## Table of Contents  
88
9- -  [ Using this Project With Conjur Open Source] ( #Using -conjur-api-dotnet-with-Conjur-Open-Source  ) 
9+ -  [ Using this Project With Conjur Open Source] ( #using -conjur-api-dotnet-with-conjur-open-source  ) 
1010-  [ Requirements] ( #requirements ) 
1111-  [ Building] ( #building ) 
1212-  [ Methods] ( #methods ) 
13- -  [ Example ] ( #example  ) 
13+ -  [ Examples ] ( #examples  ) 
1414-  [ Contributing] ( #contributing ) 
1515-  [ License] ( #license ) 
1616
17- ## Using conjur-api-dotnet with Conjur Open Source    
17+ ## Using conjur-api-dotnet with Conjur Open Source  
1818
19- Are you using this project with [ Conjur Open Source] ( https://github.com/cyberark/conjur ) ? Then we  
20- ** strongly**  recommend choosing the version of this project to use from the latest [ Conjur OSS  
21- suite release] ( https://docs.conjur.org/Latest/en/Content/Overview/Conjur-OSS-Suite-Overview.html ) .  
22- Conjur maintainers perform additional testing on the suite release versions to ensure  
23- compatibility. When possible, upgrade your Conjur version to match the  
24- [ latest suite release] ( https://docs.conjur.org/Latest/en/Content/ReleaseNotes/ConjurOSS-suite-RN.htm ) ;  
25- when using integrations, choose the latest suite release that matches your Conjur version. For any  
19+ Are you using this project with [ Conjur Open Source] ( https://github.com/cyberark/conjur ) ? Then we
20+ ** strongly**  recommend choosing the version of this project to use from the latest [ Conjur OSS
21+ suite release] ( https://docs.conjur.org/Latest/en/Content/Overview/Conjur-OSS-Suite-Overview.html ) .
22+ Conjur maintainers perform additional testing on the suite release versions to ensure
23+ compatibility. When possible, upgrade your Conjur version to match the
24+ [ latest suite release] ( https://docs.conjur.org/Latest/en/Content/ReleaseNotes/ConjurOSS-suite-RN.htm ) ;
25+ when using integrations, choose the latest suite release that matches your Conjur version. For any
2626questions, please contact us on [ Discourse] ( https://discuss.cyberarkcommons.org/c/conjur/5 ) .
2727
2828## Requirements  
2929
30- -  Conjur Enterprise (formerly DAP) v10+ or Conjur Open Source v1+
31- 
32- For Conjur Enterprise V4, use the [ V4 branch] ( https://github.com/cyberark/conjur-api-dotnet/tree/v4 ) 
30+ -  Conjur Enterprise v10+ or Conjur Open Source v1+
3331
3432-  When using the ** AWS Authenticator** , Conjur Enterprise v13+ or Conjur Cloud (Conjur OSS was not tested)
3533
3634## Building  
3735
38- This sample was built and tested with  Visual Studio 2015. 
36+ ###  Visual Studio 
3937
4038To load in Visual Studio, from the Visual Studio File menu select Open > Project/Solution > api-dotnet.sln
41-  and build the solution. This will create:
39+ and build the solution. This will create:
40+ 
41+ -  conjur-api.dll: the .NET version of the Conjur API.
42+ -  ConjurTest.dll: test DLL used for automated testing of the Conjur .NET API
43+ -  example.exe: sample application that uses the Conjur API.
4244
43-     - conjur-api.dll: the .NET version of the Conjur API. 
44-     - ConjurTest.dll: test DLL used for automated testing of the Conjur .NET API 
45-     - example.exe: sample application that uses the Conjur API. 
45+ ### Docker  
4646
47- Optionally, to build in a Docker container, it is recommended to use Mono and xbuild.
47+ To build in a Docker container, run the following commands:
48+ 
49+ ``` bash 
50+ make -C docker
51+ ./build.sh
52+ ``` 
4853
4954## Methods  
5055
5156### ` Client `  
5257
5358#### ` Client Client(uri, account) `  
59+ 
5460-  Create new Conjur instance
55-     -  ` uri `  - URI of the Conjur server. Example: ` https://myconjur.org.com/api ` 
56-     -  ` account `  - Name of the Conjur account
61+   -  ` uri `  - URI of the Conjur server. Example: ` https://myconjur.org.com/api ` 
62+   -  ` account `  - Name of the Conjur account
5763
5864#### ` void client.LogIn(string userName, string password) `  
65+ 
5966-  Login to a Conjur user
60-     -  ` userName `  - Username of Conjur user to login as
61-     -  ` password `  - Password of user
67+   -  ` userName `  - Username of Conjur user to login as
68+   -  ` password `  - Password of user
6269
6370#### ` void client.TrustedCertificates.ImportPem (string certPath) `  
71+ 
6472-  Add Conjur root certificate to system trust store
65-     -  ` certPath `  = Path to cert
73+   -  ` certPath `  = Path to cert
6674
6775#### ` void client.DisableCertCheck() `  
76+ 
6877-  Disable SSL Cert check -- used when Conjur is configured with self-signed cert. Do not use in production.
6978
7079#### ` void client.EnableCertCheck() `  
71- -  Enable SSL Cert check -- Default is to perform cert check; this method is used if there is a need to disable and enable the cert check.
7280
81+ -  Enable SSL Cert check -- Default is to perform cert check; this method is used if there is a need to disable and enable the cert check.
7382
7483#### ` client.Credential = new NetworkCredential(string userName, string apiKey) `  
84+ 
7585-  To login with an API key, use it directly
76-     -  ` userName `  - Username of user to login as
77-     -  ` apiKey `  - API key of user/host/etc
86+   -  ` userName `  - Username of user to login as
87+   -  ` apiKey `  - API key of user/host/etc
7888
7989#### ` IEnumerable<Variable> client.ListVariables(string query = null) `  
90+ 
8091-  Returns a list of variable objects
81-     -  ` query `  - Additional query parameters (not required)
92+   -  ` query `  - Additional query parameters (not required)
8293
8394#### ` uint client.CountVariables(string query = null) `  
95+ 
8496-  Return count of Conjur variables conforming to the ` query `  parameter
85-      -  ` query `  - Additional query parameters (not required)
97+   -  ` query `  - Additional query parameters (not required)
8698
8799#### ` Host client.CreateHost(string name, string hostFactoryToken) `  
100+ 
88101-  Creates a host using a host factory token
89-     -  ` name `  - Name of the host to create
90-     -  ` hostFactoryToken `  - Host factory token
102+   -  ` name `  - Name of the host to create
103+   -  ` hostFactoryToken `  - Host factory token
91104
92105#### ` client.Authenticator = new Conjur.AWSIAMAuthenticator(Conjur.Client client, string Identity, string Authenticator, string roleArn = "", string ConjurAWSRegion = "us-east-1") `  
106+ 
93107-  ** REQUIREMENTS** : Conjur Enterprise v13+ or Conjur Cloud (Conjur OSS was not tested)
94108-  Configure the client to use the AWS IAM Authenticator
95109  -  Client must be instantiated with these attributes before instantiating the AWS authenticator:
@@ -100,82 +114,88 @@ Optionally, to build in a Docker container, it is recommended to use Mono and xb
100114### ` Policy `  
101115
102116#### ` Policy client.Policy(string policyName) `  
103- -  Create a Conjur policy object 
104-    -  ` policyName `  - Name of policy
117+ 
118+ -  Create a Conjur policy object
119+   -  ` policyName `  - Name of policy
105120
106121#### ` policy.LoadPolicy(Stream policyContent) `  
122+ 
107123-  Load policy into Conjur
108-     -    ` policyContent `  - The policy
124+   -  ` policyContent `  - The policy
109125
110126### ` Variable `  
111127
112128#### ` Variable client.Variable(string name) `  
129+ 
113130-  Instantiate a Variable object
114-     -  ` name `  - Name of the variable
131+   -  ` name `  - Name of the variable
115132
116133#### ` Boolean variable.Check(string privilege) `  
134+ 
117135-  Check if the current entity has the specified privilege on this variable
118-     -  ` privilege `  - string name of the privilege to check for
119-        -  Privileges: read, create, update, delete, execute
136+   -  ` privilege `  - string name of the privilege to check for
137+     -  Privileges: read, create, update, delete, execute
120138
121139#### ` void variable.AddSecret(bytes val) `  
140+ 
122141-  Change current variable to val
123-     -  ` val `  - Value in bytes to update current variable to
142+   -  ` val `  - Value in bytes to update current variable to
124143
125144#### ` String variable.GetValue() `  
145+ 
126146-  Return the value of the current Variable
127147
128148## Examples  
129149
130- ####  Example Code  
150+ ### Example Code  
131151
132152``` csharp 
133-      //  Instantiate a Conjur Client object.
134-      //   parameter: URI - conjur appliance URI
135-      //   parameter: ACCOUNT - conjur account name
136-      //   return: Client object - if URI is incorrect errors thrown when used
137-      Client  conjurClient  =  new  Client (" https://myorg.com"  , account );
138- 
139-      //  Login with Conjur credentials like userid and password,
140-      //  or hostid and api_key, etc
141-      //   parameters: username - conjur user or host id for example
142-      //               password - conjur user password or host api key for example
143-      string  conjurAuthToken  =  conjurClient .Login (username , password );
144- 
145-      //  Check if this user has permission to get the value of variableId
146-      //  That requires execute permissions on the variable
147- 
148-      //  Instantiate a Variable object
149-      //    parameters: client - contains authentication token and conjur URI
150-      //                name - the name of the variable
151-      Variable  conjurVariable  =  new  Variable (conjurClient , variableId );
152- 
153-      //  Check if the current user has "execute" privilege required to get
154-      //  the value of the variable
155-      //    parameters: privilege - string name of the priv to check for
156-      bool  isAllowed  =  conjurVariable .Check (" execute"  );
157-      if  (! isAllowed )
158-      {
159-          Console .WriteLine (" You do not have permissions to get the value of {0}"  , variableId );
160-      }
161-      else 
162-      {
163-          Console .WriteLine (" {0} has the value: {1}"  , variableId , conjurVariable .GetValue ());
164-      }
153+ //  Instantiate a Conjur Client object.
154+ //   parameter: URI - conjur appliance URI
155+ //   parameter: ACCOUNT - conjur account name
156+ //   return: Client object - if URI is incorrect errors thrown when used
157+ Client  conjurClient  =  new  Client (" https://myorg.com"  , account );
158+ 
159+ //  Login with Conjur credentials like userid and password,
160+ //  or hostid and api_key, etc
161+ //   parameters: username - conjur user or host id for example
162+ //               password - conjur user password or host api key for example
163+ string  conjurAuthToken  =  conjurClient .Login (username , password );
164+ 
165+ //  Check if this user has permission to get the value of variableId
166+ //  That requires execute permissions on the variable
167+ 
168+ //  Instantiate a Variable object
169+ //    parameters: client - contains authentication token and conjur URI
170+ //                name - the name of the variable
171+ Variable  conjurVariable  =  new  Variable (conjurClient , variableId );
172+ 
173+ //  Check if the current user has "execute" privilege required to get
174+ //  the value of the variable
175+ //    parameters: privilege - string name of the priv to check for
176+ bool  isAllowed  =  conjurVariable .Check (" execute"  );
177+ if  (! isAllowed )
178+ {
179+     Console .WriteLine (" You do not have permissions to get the value of {0}"  , variableId );
180+ }
181+ else 
182+ {
183+     Console .WriteLine (" {0} has the value: {1}"  , variableId , conjurVariable .GetValue ());
184+ }
165185``` 
166186
167- ####  Example App  
187+ ### Example App  
168188
169189This example app shows how to:
170190
171-      - Authenticate 
172-      - Load Policy 
173-      - Check permissions to get the value of a variable 
174-      - Get the value of a variable 
175-      - Use a Host Factory token to create a new Host and get an apiKey to use with Conjur 
191+ -  Authenticate
192+ -  Load Policy
193+ -  Check permissions to get the value of a variable
194+ -  Get the value of a variable
195+ -  Use a Host Factory token to create a new Host and get an apiKey to use with Conjur
176196
177197To run the sample in Visual Studio, set the ` example `  project as the Startup
178-  Project.  To do so, in  
198+  Project.  To do so, in
179199the Solution Explorer right click over ` example `  and select ` Set as Startup Project ` .
180200
181201``` txt 
@@ -191,7 +211,7 @@ Usage: Example  <applianceURL>
191211` applianceURL ` : the applianceURL e.g. ` https://conjur.myorg.com/ ` 
192212
193213` applianceCertificatePath ` : the path and name of the Conjur appliance
194-  certificate. The easiest way to get the certifiate is to use the Conjur  
214+  certificate. The easiest way to get the certifiate is to use the Conjur
195215CLI command ` conjur init -u conjur.myorg.com -f .conjurrc ` . The certificate can be taken from any system you have run the Conjur CLI from.
196216
197217` accountName ` : The name of the account in Conjur.
@@ -203,9 +223,9 @@ CLI command `conjur init -u conjur.myorg.com -f .conjurrc`. The certificate can
203223` variableId ` : The name of an existing variable in Conjur that has a value set and for which the ` username `  has execute permissions.
204224
205225` hostFactoryToken ` : A host factory token. The easiest way to get a host
206-  factory token for testing is to add a hostfactory to a layer using  
226+  factory token for testing is to add a hostfactory to a layer using
207227the Conjur CLI command ` conjur hostfactory create `  and
208-  ` conjur hostfactory token create ` . Take the token returned from that call  
228+  ` conjur hostfactory token create ` . Take the token returned from that call
209229and pass it as the hostFactoryToken parameter to this example.
210230
211231#### Example Code with AWS Authenticator  
0 commit comments