Permify Go Library
Use Permify in server-side Go Projects.
Install
go get github.com/Permify/permify-go/v2Usage
To get started, create the Permify client using your Workspace id and API private key:
import permify `github.com/Permify/permify-go/v2`
client := client.New("workspace_id", "private_token")Create User
This method creates a user entity in Permify.
response, err := client.User.Create(user.Create{ExternalID: "user_external_id", GroupExternalID: "group_external_id", Name: "user_name", Photo: permify_go.String("user_photo"), Title: permify_go.String("user_title")})Create Role
This method creates a role entity in Permify.
response, err = client.Role.Create(role.Create{GroupExternalID: "group_external_id", Name: "role_name", Description: permify_go.String("user_photo"), Color: permify_go.String("color")})Create Group
This method creates a group entity in Permify.
response, err = client.Group.Create(group.Create{ExternalID: "external_id", Name: "name"})IsAuthorized
This method returns a decision about whether the user can do this action.
cascade create means if permission does not exist in the database, it creates a new permission and continues processing.
response, err = client.User.IsAuthorized(user.IsAuthorized{UserExternalID: "user_external_id", PermissionName: "permission_name", CascadeCreate: true, Description: permify_go.String("description")})Create Portal Session
This method creates a new portal session. More information about Permify Portal.
response, err = client.Session.Create(session.Create{GroupExternalID: "group_external_id"})For more information on how to use the Permify API, please refer to the Permify API Reference.