Skip to content

OP-016: Authorize a user for a role with caller-controlled domain order

IsAuthorized2 is invoked over the Security route on SAIF.Services.WCF.Services.Security.SecurityService; this page documents the process end to end, from route dispatch to the message the caller receives.

Field Value
Operation ID OP-016
Trigger Caller invokes IsAuthorized2 over the Security route, or IsAuthorized calls it internally with tryInternalDomainFirst = true.
Entry operation IsAuthorized2
Owning component SAIF.Services.WCF.Services.Security.SecurityService.IsAuthorized2
Inputs Request message parts listed below
Outputs Whether userId is authorized for role.
Failure behavior Generic SOAP fault, per Faults and error pipeline

Request and response

Direction Element Type Declared in Notes
Request userId string BCL (System) Account to check; validated non-blank. (Yes)
Request role string BCL (System) Role/group name to check; validated non-blank. (Yes)
Request tryInternalDomainFirst bool BCL (System) Whether the internal (Windows) domain is checked before the external LDAP domain. (Yes)
Response bool bool BCL (System) Whether userId is authorized for role.

Steps

  1. Constructor reads LOG_REQUEST_DETAILS and LDAP_EXTERNAL_KEY from appSettings inside an empty catch, resolves the external LDAP host with a literal fallback, opens the Oracle EXTUR unit of work, constructs UserFactory, and calls AuthorizationCacheService.Init when the cache is not ready (BR-WCF-018, BR-WCF-029).
  2. LogRequestDetails appends the operation name and its arguments — including userId and role — to the IIS log (BR-WCF-032).
  3. Enforce.ArgumentNotNullOrWhiteSpace on userId and role; the third guard passes role under the label "domain", so domain is never actually validated (BR-WCF-023).
  4. When tryInternalDomainFirst is true, the internal check runs first and the external check only on a false internal answer; when false, the order is reversed under the same cache/exception rules (BR-WCF-030, BR-WCF-031).
  5. AuthorizationCacheService.IsAuthorized caches the outcome as described above (BR-WCF-029).
  6. Return the boolean.
  7. On failure: directory exceptions other than the two handled SecurityException shapes are logged by the installed error handler and surfaced as a generic SOAP fault with exception detail included.

Process flow

The following diagram visualizes this process's control flow.

flowchart TD
    A["Initialize dependencies and<br>authorization cache"]
    B["Log request details"]
    C["Validate userId and role"]
    D1{"tryInternalDomainFirst"}
    D2["Internal check runs first,<br>then the external check runs<br>only on a false internal answer<br>(same cache/exception rules)"]
    D3["External check runs first,<br>then the internal check runs<br>only on a false external answer<br>(same cache/exception rules)"]
    E["Cache the authorization outcome"]
    F["Return the boolean."]
    A --> B
    B --> C
    C --> D1
    D1 -->|"true"| D2
    D1 -->|"false"| D3
    D2 --> E
    D3 --> E
    E --> F

Transaction and side effects

Aspect Finding
Unit of work OracleUnitOfWorkFactory (EXTUR), opened but not used for this decision path
Commit point Not applicable
Records written None for this path
Downstream calls Active Directory (corp.saif.com and the external LDAP host); ASP.NET HttpContext.Current.Cache
Shared state touched Reads and, on a cache miss, mutates the process-wide AuthorizationCacheService cache and the mutable ldap_external field
Repeat-call behavior A cached result short-circuits the directory calls for the TTL window

Logging

Surface Written content
HttpContext.Current.Response.AppendToLog (LogRequestDetails) Writes IIS request-detail log lines when LOG_REQUEST_DETAILS is enabled; populates the shared authorization cache
ErrorLogErrorHandler → LogService Failure-path exception logging only, carrying method signature, calling user and exception detail; see Faults and error pipeline

Faults and error handling

Failure Fault type the caller receives Produced by Source
SecurityException (uncategorized) Generic SOAP fault The ErrorLogErrorHandler installed by [LogErrorBehavior] src/WCF/SAIF.Services.WCF.Host/Services/Security/SecurityService.cs
Directory or Oracle/NHibernate exception Generic SOAP fault The ErrorLogErrorHandler installed by [LogErrorBehavior] src/WCF/SAIF.Services.WCF.Host/Services/Security/SecurityService.cs

Authorization

Requirement Enforced by Source Applies to
None in code IIS authentication on the deployment (see Activation and hosting) src/WCF/SAIF.Services.WCF.Host/Services/Security/SecurityService.cs This operation

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • src/WCF/SAIF.Services.WCF.Host/Services/Security/SecurityService.cs