Redact sensitive data
When remotely viewing a user's screen, there may be certain sensitive data that should not be viewable by the agent.
For this purpose, we provide a redaction API that automatically blocks out on device all sensitive data sources such as credit cards, social security numbers, etc. When certain data is redacted, it will never leave the user's device.
Cobrowse provides two methods for redacting sensitive data in your applications:
1. Define the redacted views in your app source code (recommended)
This is the recommended method as it will make sure your redactions are tied to app version.
Web
iOS
Android
React Native
Xamarin
You can only define redactions via the web dashboard for the web SDK. Enter CSS selectors on the dashboard settings page.
Implement the CobrowseIORedacted protocol on any UIViewController that contains sensitive views. This protocol contains one method:
1
// From this method you should return a list of the views you want
2
// Cobrowse to redact, for example:
3
- (NSArray*) redactedViews {
4
return @[ redactedTextView ];
5
}
Copied!
If making changes to your UIViewController subclasses isn't an option, we also support a delegate style method to allow you to supply this information in one place. Find out more about this by emailing us at [email protected].
Implement the CobrowseIO.Redacted interface on any Activity that contains sensitive views. This interface contains one method:
1
// From this method you should return a list of the views you want
2
// Cobrowse to redact, for example:
3
public List<View> redactedViews() {
4
List<View> redacted = new ArrayList<>();
5
redacted.add(findViewById(R.id.redact_me));
6
return redacted;
7
}
Copied!
If making changes to your Activity classes isn't an option, we also support a delegate style method to allow you to supply this information in one place. Find out more about this by emailing us at [email protected].
To redact an element in your React native application you can wrap it in a tag provided by the Cobrowse module:
1
import React, { Component } from 'react';
2
import { Text, View } from 'react-native';
3
import { Redacted } from 'cobrowse-sdk-react-native';
4
5
export default class MyComponent extends Component {
6
render() {
7
return (
8
<View style={styles.container}>
9
<Redacted>
10
<Text style={styles.instructions}>This text should be secret</Text>
11
</Redacted>
12
</View>
13
);
14
}
15
}
16
17
// ... stylesheets etc...
Copied!
Xamarin.iOS implementation
Implement the ICobrowseIORedacted interface on any UIViewController that contains sensitive views. This interface contains one RedactedViews property:
1
public partial class ViewController : UIViewController, ICobrowseIORedacted
2
{
3
// From this property you should return a list of the views you want Cobrowse to redact, for example:
4
public UIView[] RedactedViews
5
=> new[] { redactedTextView };
6
}
Copied!
Xamarin.Android implementation
Implement the CobrowseIO.IRedacted interface on any Activity that contains sensitive views. This interface contains one method:
1
[Activity]
2
public class MainActivity : AppCompatActivity, CobrowseIO.IRedacted
3
{
4
// From this method you should return a list of the views you want Cobrowse to redact, for example:
5
public IList<View> RedactedViews()
6
{
7
return new[]
8
{
9
FindViewById(Resource.Id.redact_me)
10
}
11
}
12
}
Copied!
Xamarin.Forms implementation
While it is not possible to access platform-specific UI code directly from a cross-platform project, you can easily achieve it using Effects and Custom Renderers.
In your cross-platform project declare a new Effect for marking Xamarin.Forms UI elements as redacted:
1
using Xamarin.Forms;
2
3
namespace YourAppNamespace.Forms
4
{
5
/// <summary>
6
/// A Xamarin.Forms effect that helps to redact Xamarin.Forms view in Cobrowse.io.
7
/// </summary>
8
public class CobrowseRedactedViewEffect : RoutingEffect
9
{
10
public bool IsRedacted { get; set; } = true;
11
12
public CobrowseRedactedViewEffect()
13
: base("YourAppName" + "." + nameof(CobrowseRedactedViewEffect))
14
{
15
}
16
}
17
}
Copied!
iOS-specific platform Effect would look like this:
1
using System.Collections.Generic;
2
using UIKit;
3
using Xamarin.Forms;
4
using Xamarin.Forms.Platform.iOS;
5
6
[assembly: ResolutionGroupName("YourAppName")]
7
[assembly: ExportEffect(typeof(YourAppNamespace.iOS.PlatformCobrowseRedactedViewEffect), "CobrowseRedactedViewEffect")]
8
namespace YourAppNamespace.iOS
9
{
10
public class PlatformCobrowseRedactedViewEffect : PlatformEffect
11
{
12
private static readonly List<UIView> sRedacted = new List<UIView>();
13
14
public static UIView[] RedactedViews => sRedacted.ToArray();
15
16
public PlatformCobrowseRedactedViewEffect()
17
{
18
}
19
20
protected override void OnAttached()
21
{
22
// We have to always use 'Container' and never 'Control'
23
// because 'Control' is null in 'OnDetached', at least in Xamarin.Forms 4.5.0.356
24
AddToRedacted(Container);
25
}
26
27
protected override void OnDetached()
28
{
29
RemoveFromRedacted(Container);
30
}
31
32
private static void AddToRedacted(UIView view)
33
{
34
if (view == null)
35
{
36
return;
37
}
38
sRedacted.Add(view);
39
}
40
41
private static void RemoveFromRedacted(UIView view)
42
{
43
if (view == null)
44
{
45
return;
46
}
47
if (sRedacted.Contains(view))
48
{
49
sRedacted.Remove(view);
50
}
51
}
52
}
53
}
Copied!
Then create a new default Xamarin.Forms.Page renderer which would implement ICobrowseIORedacted interface:
1
using UIKit;
2
using Xamarin.CobrowseIO;
3
using Xamarin.Forms;
4
using Xamarin.Forms.Platform.iOS;
5
6
[assembly: ExportRenderer(typeof(ContentPage), typeof(YourAppNamespace.iOS.CobrowseRedactedPageRenderer))]
7
namespace YourAppNamespace.iOS
8
{
9
public class CobrowseRedactedPageRenderer : PageRenderer, ICobrowseIORedacted
10
{
11
public UIView[] RedactedViews => PlatformCobrowseRedactedViewEffect.RedactedViews;
12
}
13
}
Copied!
Android-specific platform Effect would look like this:
1
using System.Collections.Generic;
2
using Xamarin.Forms;
3
using Xamarin.Forms.Platform.Android;
4
using AView = Android.Views.View;
5
6
[assembly: ResolutionGroupName("YourAppName")]
7
[assembly: ExportEffect(typeof(YourAppNamespace.Android.PlatformCobrowseRedactedViewEffect), "CobrowseRedactedViewEffect")]
8
namespace YourAppNamespace.Android
9
{
10
public class PlatformCobrowseRedactedViewEffect : PlatformEffect
11
{
12
private static readonly List<AView> sRedacted = new List<AView>();
13
14
public static IList<AView> RedactedViews => sRedacted;
15
16
protected override void OnAttached()
17
{
18
AddToRedacted(Control ?? Container);
19
}
20
21
protected override void OnDetached()
22
{
23
RemoveFromRedacted(Control ?? Container);
24
}
25
26
private static void AddToRedacted(AView view)
27
{
28
if (view == null)
29
{
30
return;
31
}
32
sRedacted.Add(view);
33
}
34
35
private static void RemoveFromRedacted(AView view)
36
{
37
if (view == null)
38
{
39
return;
40
}
41
if (sRedacted.Contains(view))
42
{
43
sRedacted.Remove(view);
44
}
45
}
46
}
47
}
Copied!
Then implement CobrowseIO.IRedacted interface in your Forms activity:
1
using System.Collections.Generic;
2
using Android.App;
3
using Xamarin.CobrowseIO;
4
using AView = Android.Views.View;
5
6
namespace YourAppNamespace.Android
7
{
8
[Activity]
9
public class MainActivity
10
: global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity,
11
CobrowseIO.IRedacted
12
{
13
public IList<AView> RedactedViews()
14
{
15
return PlatformCobrowseRedactedViewEffect.RedactedViews;
16
}
17
}
18
}
Copied!
2. Use the Cobrowse web dashboard to define redacted views
You can also define redactions using a selector entered into the web dashboard. This can be useful if your app is already in production and you need to redact a field retrospectively, either due to a missed redaction entry in the app build or changing requirements. Visit the dashboard settings to enter redaction selectors.
Last modified 1yr ago
Copy link