Backend / Server
Go
title: “Go” sidebarTitle: “Go” icon: golang
A comprehensive Go SDK for integrating Rownd authentication, user management, and group management into your applications.
Installation
Features
- Token validation and management with EdDSA support
- User authentication and profile management
- Group management with member roles and invites
- HTTP middleware for authentication
- Comprehensive error handling
- Configurable caching for JWKs and WKC
Quick start
Quick start with examples
Creating users
Searching for users
Group management examples
Token validation with claims
Helpful utilities
Authentication & token validation
Token validation
HTTP middleware
User management
User operations (CRUD)
Group management
Groups
Group invites
Group membership management
The difference between Group IDs and User IDs
In Rownd’s group system, there are two important identifiers:
user_id
: The unique identifier for a Rownd user (e.g., “user_a7b53gwdaml5jt7t71442ng7”)member_id
: The unique identifier for a user’s membership in a specific group (e.g., “member_dnn5g4e3q5aptail2gr43kpj”)
A single user can be a member of multiple groups, with a different member_id
for each group membership.
Managing group members
Important notes about group membership
-
Member ID vs User ID
- Use
member_id
when managing a specific membership (updating roles, removing from group) - Use
user_id
when adding a new member to a group - A user (
user_id
) can have multiple memberships (member_id
s) across different groups
- Use
-
Group Ownership
- Groups must always have at least one owner
- When removing the last owner, transfer ownership first
- Example of transferring ownership:
-
Member States
active
: Normal membershipsuspended
: Temporarily restricted accessinvited
: Pending acceptance of invitation
-
Common Role Types
owner
: Full administrative controladmin
: Can manage members and contenteditor
: Can modify contentviewer
: Read-only access- Custom roles can be defined as needed
Group ownership and member management rules
Group ownership rules
-
Automatic owner assignment
- The first member added to a group automatically receives the “owner” role
- Example of first member creation:
-
Owner requirements
- Every group must maintain at least one owner at all times
- Attempting to remove the last owner will result in an error
-
Group deletion requirements
- A group must have at least one member. To remove all members, delete the group.
- Correct order of operations:
Error handling
The SDK provides structured error types for better error handling:
Configuration options
Client options
Request options
Testing
Run all tests:
Run specific tests:
Run with timeout:
Types reference
Auth levels
Group admission policies
Environment setup
Using environment variables
Create a .env
file in your project root:
Load environment variables in your code:
Environment Files
- Add
.env
to your.gitignore
:
- For testing, create a separate
.env.test
:
- Load different env files based on environment:
License
This project is licensed under the MIT License - see the LICENSE file for details.