Documentation ¶
Overview ¶
Package auth provides the APIs to get information about the authenticated users.
For more information about how authentication works with Encore applications see https://encore.dev/docs/develop/auth.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Data ¶
func Data() (_ any)
Data returns the structured auth data for the request. It returns nil if the request was made without authentication details, and the API endpoint does not require them.
Expected usage is to immediately cast it to the registered auth data type:
usr, ok := auth.Data().(*user.Data) if !ok { /* ... */ }
func WithContext ¶ added in v0.17.0
WithContext returns a new context that sets the auth information for outgoing API calls. It does not affect the auth information for the current request.
Passing in an empty string as the uid results in unsetting the auth information, causing future API calls to behave as if there was no authenticated user.
If the application's auth handler returns custom auth data, two additional requirements exist. First, the data parameter passed to WithContext must be of the same type as the auth handler returns. Second, if the uid argument is not the empty string then data may not be nil. If these requirements are not met, API calls made with these options will not be made and will immediately return a client-side error.