1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//! Group-based access control for organizing users into logical collections.
//!
//! Groups provide a flexible way to organize users into collections for access control
//! purposes. Unlike hierarchical roles, groups are typically used for organizational
//! structures like departments, teams, projects, or any logical grouping of users.
//!
//! # Key Features
//!
//! - **Organizational structure** - Model departments, teams, or project memberships
//! - **Flexible membership** - Users can belong to multiple groups simultaneously
//! - **Simple equality** - Groups are compared by name (no hierarchy)
//! - **Access policies** - Use groups in access control policies alongside roles
//!
//! # Creating and Using Groups
//!
//! ```rust
//! use axum_gate::prelude::Group;
//! use axum_gate::authz::AccessPolicy;
//! use axum_gate::prelude::Role;
//!
//! // Create groups for different organizational units
//! let engineering = Group::new("engineering");
//! let marketing = Group::new("marketing");
//! let qa_team = Group::new("qa-team");
//! let project_alpha = Group::new("project-alpha");
//!
//! // Use groups in access policies
//! let policy = AccessPolicy::<Role, Group>::require_group(engineering)
//! .or_require_group(marketing);
//! ```
//!
//! # Group-Based Access Control
//!
//! ```rust
//! use axum_gate::accounts::Account;
//! use axum_gate::authz::AccessPolicy;
//! use axum_gate::prelude::{Gate, Role, Group};
//! use axum_gate::codecs::jwt::{JsonWebToken, JwtClaims};
//! use std::sync::Arc;
//!
//! // Create an account with multiple group memberships
//! let account = Account::new(
//! "developer@example.com",
//! &[Role::User],
//! &[Group::new("engineering"), Group::new("backend-team"), Group::new("project-alpha")]
//! );
//!
//! // Create access policies for different areas
//! # let jwt_codec = Arc::new(JsonWebToken::<JwtClaims<Account<Role, Group>>>::default());
//! let engineering_gate = Gate::cookie("my-app", Arc::clone(&jwt_codec))
//! .with_policy(AccessPolicy::<Role, Group>::require_group(Group::new("engineering")));
//!
//! let project_gate = Gate::cookie("my-app", Arc::clone(&jwt_codec))
//! .with_policy(
//! AccessPolicy::<Role, Group>::require_group(Group::new("project-alpha"))
//! .or_require_group(Group::new("project-beta"))
//! );
//!
//! // Combine with role requirements
//! let admin_or_engineering = Gate::cookie("my-app", jwt_codec)
//! .with_policy(
//! AccessPolicy::<Role, Group>::require_role(Role::Admin)
//! .or_require_group(Group::new("engineering"))
//! );
//! ```
//!
//! # Common Group Patterns
//!
//! ```rust
//! use axum_gate::prelude::Group;
//!
//! // Department-based groups
//! let groups = vec![
//! Group::new("engineering"),
//! Group::new("marketing"),
//! Group::new("sales"),
//! Group::new("support"),
//! ];
//!
//! // Project-based groups
//! let project_groups = vec![
//! Group::new("project-alpha"),
//! Group::new("project-beta"),
//! Group::new("maintenance"),
//! ];
//!
//! // Team-based groups
//! let team_groups = vec![
//! Group::new("frontend-team"),
//! Group::new("backend-team"),
//! Group::new("devops-team"),
//! Group::new("qa-team"),
//! ];
//! ```
use crateCommaSeparatedValue;
use ;
/// A group represents a collection of users for access control purposes.
///
/// Groups are typically used to represent organizational units like departments,
/// teams, projects, or any other logical grouping of users. They provide an
/// additional dimension of access control beyond roles.
///
/// # Example Usage
/// ```rust
/// use axum_gate::prelude::Group;
///
/// let engineering = Group::new("engineering");
/// let backend_team = Group::new("backend-team");
/// let project_alpha = Group::new("project-alpha");
///
/// println!("Group name: {}", engineering.name());
/// ```
;