| | | 1 | | using System.Text.Json; |
| | | 2 | | using Elsa.ExternalAuthentication.Models; |
| | | 3 | | |
| | | 4 | | namespace Elsa.ExternalAuthentication.Permissions; |
| | | 5 | | |
| | | 6 | | internal static class BuiltInPermissionGrantSourceDescriptors |
| | | 7 | | { |
| | | 8 | | public static IReadOnlyList<SettingFieldDescriptor> Mapping(string defaultClaimType) => |
| | 0 | 9 | | [ |
| | 0 | 10 | | Field( |
| | 0 | 11 | | "claimType", |
| | 0 | 12 | | "Projected claim type", |
| | 0 | 13 | | "The normalized projected claim whose values are matched.", |
| | 0 | 14 | | "string", |
| | 0 | 15 | | "text", |
| | 0 | 16 | | JsonSerializer.SerializeToElement(defaultClaimType)), |
| | 0 | 17 | | Field( |
| | 0 | 18 | | "mappings", |
| | 0 | 19 | | "Claim value mappings", |
| | 0 | 20 | | "A JSON object or array mapping explicit claim values to arrays of Elsa permission strings.", |
| | 0 | 21 | | "json", |
| | 0 | 22 | | "json", |
| | 0 | 23 | | JsonSerializer.SerializeToElement(Array.Empty<object>())) |
| | 0 | 24 | | ]; |
| | | 25 | | |
| | | 26 | | public static IReadOnlyList<SettingFieldDescriptor> PassThrough() => |
| | 0 | 27 | | [ |
| | 0 | 28 | | Field( |
| | 0 | 29 | | "claimType", |
| | 0 | 30 | | "Projected permission claim type", |
| | 0 | 31 | | "The normalized projected claim containing candidate Elsa permission strings.", |
| | 0 | 32 | | "string", |
| | 0 | 33 | | "text", |
| | 0 | 34 | | JsonSerializer.SerializeToElement("permissions")), |
| | 0 | 35 | | Field( |
| | 0 | 36 | | "allowedPermissions", |
| | 0 | 37 | | "Allowed permission boundary", |
| | 0 | 38 | | "Only these exact permission strings may pass through from the projected claim.", |
| | 0 | 39 | | "string-array", |
| | 0 | 40 | | "string-array", |
| | 0 | 41 | | JsonSerializer.SerializeToElement(Array.Empty<string>())) |
| | 0 | 42 | | ]; |
| | | 43 | | |
| | | 44 | | private static SettingFieldDescriptor Field(string name, string displayName, string description, string valueType, s |
| | 0 | 45 | | new( |
| | 0 | 46 | | name, |
| | 0 | 47 | | displayName, |
| | 0 | 48 | | description, |
| | 0 | 49 | | valueType, |
| | 0 | 50 | | true, |
| | 0 | 51 | | uiHint, |
| | 0 | 52 | | defaultValue, |
| | 0 | 53 | | [], |
| | 0 | 54 | | new SettingFieldValidation(MaximumLength: 16_384), |
| | 0 | 55 | | false, |
| | 0 | 56 | | false, |
| | 0 | 57 | | null, |
| | 0 | 58 | | null, |
| | 0 | 59 | | false); |
| | | 60 | | } |