| 879 | } |
| 880 | |
| 881 | func (context *DatabaseContext) Authenticator(ctx context.Context) *auth.Authenticator { |
| 882 | context.BucketLock.RLock() |
| 883 | defer context.BucketLock.RUnlock() |
| 884 | |
| 885 | sessionCookieName := auth.DefaultCookieName |
| 886 | if context.Options.SessionCookieName != "" { |
| 887 | sessionCookieName = context.Options.SessionCookieName |
| 888 | } |
| 889 | |
| 890 | var channelsWarningThreshold *uint32 |
| 891 | if context.Options.UnsupportedOptions != nil && context.Options.UnsupportedOptions.WarningThresholds != nil { |
| 892 | channelsWarningThreshold = context.Options.UnsupportedOptions.WarningThresholds.ChannelsPerUser |
| 893 | } |
| 894 | |
| 895 | // Authenticators are lightweight & stateless, so it's OK to return a new one every time |
| 896 | authenticator := auth.NewAuthenticator(context.MetadataStore, context, auth.AuthenticatorOptions{ |
| 897 | ClientPartitionWindow: context.Options.ClientPartitionWindow, |
| 898 | ChannelsWarningThreshold: channelsWarningThreshold, |
| 899 | SessionCookieName: sessionCookieName, |
| 900 | BcryptCost: context.Options.BcryptCost, |
| 901 | LogCtx: ctx, |
| 902 | Collections: context.CollectionNames, |
| 903 | MetaKeys: context.MetadataKeys, |
| 904 | }) |
| 905 | |
| 906 | return authenticator |
| 907 | } |
| 908 | |
| 909 | // UseLegacySyncDocsIndex returns true there is an index over all docs starting with _sync, or if there are individual indexes for users and roles. |
| 910 | func (context *DatabaseContext) UseLegacySyncDocsIndex() bool { |