Integration/Tutorials/Security.md
... ...
@@ -16,24 +16,23 @@ Type of security|Example|Implementation Details
16 16
17 17
###Login Security
18 18
19
-To enable basic login security, add the following code to the PostLogin() method of your CustomAdHocConfig class. This is normally found in Global.asax file. The code should look up user credentials from your application, database or windows authentication and provide it to the Izenda Reports API. Furthermore, specifying your login page will ensure that users do not see reports without being logged in.
19
+To enable basic login security, add the following code to the ``InitializeReporting()`` method of your CustomAdHocConfig class. This is normally found in Global.asax file. The code should look up user credentials from your application, database or windows authentication and provide it to the Izenda Reports API. Furthermore, specifying your login page will ensure that users do not see reports without being logged in. If a login page is specified this way, you should ensure that ``InitializeReporting()`` is called again after the login process to ensure the user is properly authenticated.
20 20
21 21
```c#
22
-public override void PostLogin()
22
+public static void InitializeReporting()
23 23
{
24
- Izenda.AdHoc.AdHocSettings.CurrentUserName = LookupUserName();
25
- Izenda.AdHoc.AdHocSettings.CurrentUserIsAdmin = LookupAdminRole();
26
- AdHocSettings.RequireLogin = true;
27
- AdHocSettings.LoginUrl = "/App/Login.aspx";
24
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE";
25
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE";
26
+ AdHocSettings.CurrentUserName = LookupUserName();
27
+ AdHocSettings.CurrentUserIsAdmin = LookupAdminRole();
28
+ AdHocSettings.CurrentUserTenantId = GetTenantID();
29
+ AdHocSettings.CurrentUserRoles = new string[] {(string)HttpContext.Current.Session["Role"]};
30
+ AdHocSettings.VisibleDataSources = new string[] { "Products", "Orders", "Customers" };
31
+ AdHocsettings.LoginPage = "YOUR_LOGIN_PAGE.aspx";
32
+ AdHocSettings.RequireLogin = true;
28 33
}
29 34
```
30 35
31
-The method will need to be called from your login process with the following line.
32
-
33
-```c#
34
-Izenda.AdHoc.AdHocSettings.AdHocConfig.PostLogin()
35
-```
36
-
37 36
###Data Sources
38 37
39 38
The API allows control over which data sources a user sees based on their credentials. In the following example, members of the "Sales" role would see additional data sources that normal users would not. Any reports that utilize these data sources would only be visible to members of the sales role.
... ...
@@ -60,54 +59,62 @@ Izenda.AdHoc.AdHocSettings.AdHocConfig.PostLogin()
60 59
61 60
Once the login security is implemented, users can set the shared and read only status of a report. If a report is shared, other members of that tenant will be able to see it. If it is marked read-only, users will be able to load the report, but any modifications will need to be saved as a different report name. These limitations do not apply to users with admin rights enabled via CurrentUserIsAdmin.
62 61
63
-```c#
64
-public override void PostLogin()
65
-{
66
- Izenda.AdHoc.AdHocSettings.CurrentUserName = LookupUserName();
67
-}
68
-```
69
-
70
-**This is a screen shot of the Misc tab in the Report Designer showing the "Shared" & "Read Only" checkboxes that a user can select on a per report basis.**
62
+![Share and read only](http://wiki.izenda.us/Integration/Share-and-Read_only.png)
71 63
72
-![](http://wiki.izenda.us/Integration/Share-and-Read_only.png)
64
+**A screenshot of the Misc tab in the Report Designer showing the "Shared" & "Read Only" checkboxes that a user can select on a per report basis.**
73 65
74 66
###Custom Report Control
75 67
76 68
To apply additional constraints to which users see what reports, it is necessary to override the ListReports method. See Report Management for additional details.
77 69
78
-```c#
79
-public override Izenda.AdHoc.ReportInfo[] ListReports()
80
-{ Return filtered list}
70
+```csharp
71
+public override ReportInfo[] FilteredListReports() {
72
+ ReportInfo[] reports = ListReports(); //Get the list of loaded reports. Can be overridden or used as-is
73
+ ArrayList result = new ArrayList();
74
+
75
+ foreach (ReportInfo info in reports) {
76
+ if (info.Category == "Hidden reports")
77
+ continue;
78
+ ReportSet reportSet = LoadFilteredReportSet(info.Name);
79
+ if (reportSet != null && reportSet.CanBeLoaded)
80
+ result.Add(info);
81
+ }
82
+ return (ReportInfo[])result.ToArray(typeof(ReportInfo));
83
+ }
81 84
```
82 85
83 86
###Overwriting and Deleting Reports</a>
84 87
85
-The API allows control of deleting or modifying reports. Reports can be accessed as Read-Only and can not be modified or deleted.
88
+The API allows control of deleting or modifying reports. Reports marked Read-Only can not be modified or deleted even if the settings below are enabled.
86 89
87 90
```c#
88
- public override void ConfigureSettings()
91
+ public static void InitializeReporting()
89 92
{
90 93
AdHocSettings.AllowOverwritingReports = true;
91 94
AdHocSettings.AllowDeletingReports = true;
92 95
}
93 96
```
94 97
95
-###Altering Capabilities by Role
98
+###Altering Capabilities by Role and Tenant ID
96 99
97
-The API allows for over a hundred features of Izenda reports to be hidden or altered based on the user's role. All settings get applied on a per-user basis.
100
+The versatility of Izenda reports allows for all settings to be applied on a per-user basis. The only limit to the customization level of Izenda's settings is your relevant coding experience, since this does require basic knowledge of either VB.NET or C#.
98 101
The following code applies properties like the connection string, where reports are stored and visibility of the modify button modify button based on the user.
99 102
100 103
```c#
101
-public override void PostLogin()
104
+public static void InitializeReporting()
102 105
{
106
+ //GetConnectionForUser, GetUserCompany, GetUserDepartment, GetUserRole, and GetTables are all user-defined methods in global.asax
107
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE";
103 108
//Set connection string per-tenant
104 109
AdHocSettings.SqlServerConnectionString = GetConnectionForUser();
105 110
//Set the stored reports file folder path per-tenant
106 111
AdHocSettings.ReportsPath="\\" GetUserCompany() "\\"
107
- GetUserDepartment();
112
+ AdHocSettings.CurrentUserTenantId = GetUserDepartment(); //Organizational level security
113
+ AdHocSettings.CurrentUserRoles = new string[]{GetUserRole()}; //Role based security
108 114
//Set table and view access
109
- AdHocSettings.VisibleDataSources = GetTables(GetUserRole);
110
- if (GetUserRole()=="PowerUser")
115
+
116
+ AdHocSettings.VisibleDataSources = GetTables(AdHocSettings.CurrentUserRoles);
117
+ if (AdHocSettings.CurrentUserRoles.Contains("PowerUser")) //User level security
111 118
{
112 119
AdHocSettings.ShowModifyButton=true;
113 120
AdHocSettings.AllowDeletingReports=false;
... ...
@@ -121,13 +128,15 @@ The method will need to be called from your login process with the following lin
121 128
Izenda.AdHoc.AdHocSettings.AdHocConfig.PostLogin()
122 129
```
123 130
124
-###Field/Record or Tenant Level Security
131
+###Field/Record Level Security
125 132
126 133
Many applications limit users to specific records based on their credentials. The HiddenFilters API Setting may be used to add hidden filters to reports which limit the results based on the user, their credentials and their tenant. In this example, anyone reporting on the AcmeWidgetSales view will be limited to data in their TerritoryID.
127 134
128 135
```c#
129
-public override void PostLogin()
136
+public static void InitializeReporting()
130 137
{
138
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE";
139
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE";
131 140
AdHocSettings.HiddenFilters["AccountID"] = AccountID;
132 141
//Set the account tenancy
133 142
if (!Izenda.AdHoc.AdHocSettings.CurrentUserIsAdmin)