<!--
{
  "availability" : [
    "macOS: 10.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SecurityInterface",
  "identifier" : "/documentation/SecurityInterface/SFAuthorizationView",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Security Interface"
    ],
    "preciseIdentifier" : "c:objc(cs)SFAuthorizationView"
  },
  "title" : "SFAuthorizationView"
}
-->

# SFAuthorizationView

The class responsible for displaying a lock icon that can be used to indicate that a user interface has restricted access.

```
class SFAuthorizationView
```

## Overview

The lock appears locked when the user must be authorized and appears open when the user has been authorized. The closed and open lock icons of the authorization view are shown in the following figure.

![Authorization view lock icon](images/com.apple.securityinterface/media-1965610.gif)

When you add an authorization view as a custom view to a window or dialog box, you must initialize it before it displays correctly. To initialize the view, use the [`setString(_:)`](/documentation/SecurityInterface/SFAuthorizationView/setString(_:)) method to create a default rights structure (containing a prompt string) or the [`setAuthorizationRights(_:)`](/documentation/SecurityInterface/SFAuthorizationView/setAuthorizationRights(_:)) method to specify a rights structure. You must also either specify automatic updates ([`setAutoupdate(_:)`](/documentation/SecurityInterface/SFAuthorizationView/setAutoupdate(_:)) or [`setAutoupdate(_:interval:)`](/documentation/SecurityInterface/SFAuthorizationView/setAutoupdate(_:interval:))) or perform a manual update ([`updateStatus(_:)`](/documentation/SecurityInterface/SFAuthorizationView/updateStatus(_:))) to set the lock icon to its initial state.

You can implement delegate methods that are invoked when the authorization view changes state. You can optionally implement the delegate methods to obtain the state of the authorization object when you are using an authorization view.

When the user clicks a locked authorization view icon, the Security Server displays an authentication dialog (to request a user name and password, for example). When the user provides the requested credentials, the lock icon unlocks and the user is considered preauthorized to perform the functions specified by the authorization rights structure. You can call the [`updateStatus(_:)`](/documentation/SecurityInterface/SFAuthorizationView/updateStatus(_:)) method to determine whether the user has been preauthorized: this method returns <doc://com.apple.documentation/documentation/Swift/true> if the view is in the unlocked state, otherwise <doc://com.apple.documentation/documentation/Swift/false>. Before committing changes or performing actions that require authorization, you should check the user’s authorization again, even if they are preauthorized.

The default behavior of this view is to preauthorize rights; if this is not possible it unlocks and waits for authorization to be checked when explicitly required.

## Topics

### Setting up the authorization view

[`-  setString:`](/documentation/SecurityInterface/SFAuthorizationView/setString(_:))

Sets the requested-right string to use with the default authorization rights set.

[`-  setAuthorizationRights:`](/documentation/SecurityInterface/SFAuthorizationView/setAuthorizationRights(_:))

Sets the authorization rights for this view.

[`-  setAutoupdate:`](/documentation/SecurityInterface/SFAuthorizationView/setAutoupdate(_:))

Sets the authorization view to update itself automatically.

[`-  setAutoupdate:interval:`](/documentation/SecurityInterface/SFAuthorizationView/setAutoupdate(_:interval:))

Sets the authorization view to update itself at a specific interval.

[`-  setFlags:`](/documentation/SecurityInterface/SFAuthorizationView/setFlags(_:))

Sets the current authorization flags for the view.

[`-  setEnabled:`](/documentation/SecurityInterface/SFAuthorizationView/setEnabled(_:))

Sets the current state of the authorization view.

### Setting and getting the delegate for the view

[`-  setDelegate:`](/documentation/SecurityInterface/SFAuthorizationView/setDelegate(_:))

Sets the delegate for this authorization view.

[`-  delegate`](/documentation/SecurityInterface/SFAuthorizationView/delegate())

Returns the delegate for this view.

### Updating the view

[`-  updateStatus:`](/documentation/SecurityInterface/SFAuthorizationView/updateStatus(_:))

Manually updates the authorization view.

### Getting information about the authorization view

[`-  authorization`](/documentation/SecurityInterface/SFAuthorizationView/authorization())

Returns the authorization object associated with this view.

[`-  authorizationRights`](/documentation/SecurityInterface/SFAuthorizationView/authorizationRights())

Returns the authorization rights for this view.

[`-  authorizationState`](/documentation/SecurityInterface/SFAuthorizationView/authorizationState())

Returns the current state of the authorization view.

[`-  isEnabled`](/documentation/SecurityInterface/SFAuthorizationView/isEnabled())

Indicates whether the authorization view is enabled (<doc://com.apple.documentation/documentation/Swift/true>) or disabled (<doc://com.apple.documentation/documentation/Swift/false>).

### Setting the authorization state

[`-  authorize:`](/documentation/SecurityInterface/SFAuthorizationView/authorize(_:))

Attempts to unlock the lock icon in the view.

[`-  deauthorize:`](/documentation/SecurityInterface/SFAuthorizationView/deauthorize(_:))

Sets the authorization state to unauthorized and locks the lock icon in the view.

### Delegate methods

  <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/authorizationViewShouldDeauthorize(_:)>

  <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/authorizationViewCreatedAuthorization(_:)>

  <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/authorizationViewDidAuthorize(_:)>

  <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/authorizationViewDidDeauthorize(_:)>

  <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/authorizationViewDidHide(_:)>

  <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/authorizationViewReleasedAuthorization(_:)>

### Constants

[`SFAuthorizationViewState`](/documentation/SecurityInterface/SFAuthorizationViewState)

Defines the current state of the authorization view.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSStandardKeyBindingResponding`](/documentation/AppKit/NSStandardKeyBindingResponding)

[`NSDraggingDestination`](/documentation/AppKit/NSDraggingDestination)

[`Sendable`](/documentation/Swift/Sendable)

[`NSAccessibilityElementProtocol`](/documentation/AppKit/NSAccessibilityElementProtocol)

[`NSTouchBarProvider`](/documentation/AppKit/NSTouchBarProvider)

[`NSUserActivityRestoring`](/documentation/AppKit/NSUserActivityRestoring)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`NSAppearanceCustomization`](/documentation/AppKit/NSAppearanceCustomization)

[`NSAccessibilityProtocol`](/documentation/AppKit/NSAccessibilityProtocol)

[`NSAnimatablePropertyContainer`](/documentation/AppKit/NSAnimatablePropertyContainer)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSUserInterfaceItemIdentification`](/documentation/AppKit/NSUserInterfaceItemIdentification)

### Inherits From

[`NSView`](/documentation/AppKit/NSView)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)