solarnetwork-api-core
    Preparing search index...

    Class SecurityPolicy

    An immutable set of security restrictions that can be attached to other objects, like auth tokens.

    Use the Domain.SecurityPolicyBuilder to create instances of this class with a fluent API.

    Implements

    Index

    Constructors

    • Constructor.

      Parameters

      • OptionalnodeIds: number[] | Set<number>

        the node IDs to restrict to, or undefined for no restriction

      • OptionalsourceIds: string[] | Set<string>

        the source ID to restrict to, or undefined for no restriction

      • Optionalaggregations: Aggregation[] | Set<Aggregation>

        the aggregation names to restrict to, or undefined for no restriction

      • OptionalminAggregation: Aggregation

        if specified, a minimum aggregation level that is allowed

      • OptionallocationPrecisions: LocationPrecision[] | Set<LocationPrecision>

        the location precision names to restrict to, or undefined for no restriction

      • OptionalminLocationPrecision: LocationPrecision

        if specified, a minimum location precision that is allowed

      • OptionalnodeMetadataPaths: string[] | Set<string>

        the SolarNodeMetadata paths to restrict to, or undefined for no restriction

      • OptionaluserMetadataPaths: string[] | Set<string>

        the UserNodeMetadata paths to restrict to, or undefined for no restriction

      Returns SecurityPolicy

    Accessors

    • get nodeMetadataPaths(): undefined | Set<string>

      Get the node metadata paths.

      Returns undefined | Set<string>

      the node metadata paths, or undefined

    • get userMetadataPaths(): undefined | Set<string>

      Get the user metadata paths.

      Returns undefined | Set<string>

      the user metadata paths, or undefined

    Methods

    • Apply this policy's restrictions on a filter.

      You can use this method to enforce aspects of a security policy on a SecurityPolicyFilter. For example:

      const policy = SecurityPolicy.fromJsonObject({
      nodeIds: [1, 2],
      sourceIds: ["/s1/**"]
      });

      const filter = policy.restrict({
      nodeIds: new Set([2, 3, 4]),
      sourceIds: new Set(["/s1/a", "/s1/a/b", "/s2/a", "/s3/a"])
      });

      // now filter contains only the node/source IDs allowed by the policy:
      {
      nodeIds: new Set([2]),
      sourceIds: new Set(["/s1/a", "/s1/a/b"])
      };

      Parameters

      Returns SecurityPolicyFilter

      a new filter instance

    • Get this object in standard JSON form.

      An example result looks like this:

      {
      "nodeIds": [1,2,3],
      "sourceIds": ["a", "b", "c"]
      "aggregations": ["Hour"]
      }

      Returns Record<string, any>

      an object, ready for JSON encoding