# Security

## Get User Security Settings

`client.User.Security.Get(ctx) (*UserSecurity, error)`

**get** `/v1/user/security`

Get the current user's security settings

### Returns

- `type UserSecurity struct{…}`

  User security settings response.

  - `SourceIPRule SourceIPRuleResponse`

    IP filter rules.

    - `Allowed []string`

      List of IPv4 CIDR addresses to allow.

    - `Blocked []string`

      List of IPv4 CIDR addresses to deny.

  - `CreatedAt Time`

    When the user security settings were created.

  - `UpdatedAt Time`

    When the user security settings were updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  userSecurity, err := client.User.Security.Get(context.TODO())
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", userSecurity.SourceIPRule)
}
```

#### Response

```json
{
  "source_ip_rule": {
    "allowed": [
      "192.168.1.0/24",
      "10.0.0.0/8"
    ],
    "blocked": [
      "192.168.1.100/32"
    ]
  },
  "created_at": "2025-01-01T00:00:00Z",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Update User Security Settings

`client.User.Security.Update(ctx, body) (*UserSecurity, error)`

**patch** `/v1/user/security`

Update the current user's security settings

### Parameters

- `body SecurityUpdateParams`

  - `SourceIPRule param.Field[SourceIPRule]`

    IP filter rules.

### Returns

- `type UserSecurity struct{…}`

  User security settings response.

  - `SourceIPRule SourceIPRuleResponse`

    IP filter rules.

    - `Allowed []string`

      List of IPv4 CIDR addresses to allow.

    - `Blocked []string`

      List of IPv4 CIDR addresses to deny.

  - `CreatedAt Time`

    When the user security settings were created.

  - `UpdatedAt Time`

    When the user security settings were updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/user"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  userSecurity, err := client.User.Security.Update(context.TODO(), user.SecurityUpdateParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", userSecurity.SourceIPRule)
}
```

#### Response

```json
{
  "source_ip_rule": {
    "allowed": [
      "192.168.1.0/24",
      "10.0.0.0/8"
    ],
    "blocked": [
      "192.168.1.100/32"
    ]
  },
  "created_at": "2025-01-01T00:00:00Z",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Domain Types

### User Security

- `type UserSecurity struct{…}`

  User security settings response.

  - `SourceIPRule SourceIPRuleResponse`

    IP filter rules.

    - `Allowed []string`

      List of IPv4 CIDR addresses to allow.

    - `Blocked []string`

      List of IPv4 CIDR addresses to deny.

  - `CreatedAt Time`

    When the user security settings were created.

  - `UpdatedAt Time`

    When the user security settings were updated.
