@@ -118,12 +118,12 @@ type OrganizationMember struct {
118118
119119// ExtractOrganizationMemberParam grabs a user membership from the "organization" and "user" URL parameter.
120120// This middleware requires the ExtractUser and ExtractOrganization middleware higher in the stack
121- func ExtractOrganizationMemberParam (db database.Store , auth func ( r * http. Request , action policy. Action , object rbac. Objecter ) bool )func (http.Handler ) http.Handler {
121+ func ExtractOrganizationMemberParam (db database.Store )func (http.Handler ) http.Handler {
122122return func (next http.Handler ) http.Handler {
123123return http .HandlerFunc (func (rw http.ResponseWriter ,r * http.Request ) {
124124ctx := r .Context ()
125125organization := OrganizationParam (r )
126- _ ,members ,done := ExtractOrganizationMember (ctx ,auth ,rw ,r ,db ,organization .ID )
126+ _ ,members ,done := ExtractOrganizationMember (ctx ,nil ,rw ,r ,db ,organization .ID )
127127if done {
128128return
129129}
@@ -194,12 +194,12 @@ func ExtractOrganizationMember(ctx context.Context, auth func(r *http.Request, a
194194return nil ,nil ,true
195195}
196196
197- if auth (r ,policy .ActionRead ,user ) {
197+ if auth != nil && auth (r ,policy .ActionRead ,user ) {
198198return & user ,organizationMembers ,true
199199}
200200
201201// If the user cannot be read and 0 memberships exist, throw a 404 to not
202- // leak the userexistance .
202+ // leak the userexistence .
203203if len (organizationMembers )== 0 {
204204httpapi .ResourceNotFound (rw )
205205return nil ,nil ,true
@@ -209,7 +209,11 @@ func ExtractOrganizationMember(ctx context.Context, auth func(r *http.Request, a
209209}
210210
211211type OrganizationMembers struct {
212- User * database.User
212+ // User is `nil` if the caller is not allowed access to the site wide
213+ // user object.
214+ User * database.User
215+ // Memberships can only be length 0 if `user != nil`. If `user == nil`, then
216+ // memberships will be at least length 1.
213217Memberships []OrganizationMember
214218}
215219
@@ -226,6 +230,9 @@ func (om OrganizationMembers) UserID() uuid.UUID {
226230
227231// ExtractOrganizationMembersParam grabs all user organization memberships.
228232// Only requires the "user" URL parameter.
233+ //
234+ // Use this if you want to grab as much information for a user as you can.
235+ // From an organization context, site wide user information might not available.
229236func ExtractOrganizationMembersParam (db database.Store ,auth func (r * http.Request ,action policy.Action ,object rbac.Objecter )bool )func (http.Handler ) http.Handler {
230237return func (next http.Handler ) http.Handler {
231238return http .HandlerFunc (func (rw http.ResponseWriter ,r * http.Request ) {