handler

package
v1.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2019 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserRecordLastLoginAtKey is the key for the time when the user
	// last logged in.
	UserRecordLastLoginAtKey = "last_login_at"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetUploadHandler

type AssetUploadHandler struct {
	AssetStore  skyAsset.Store   `inject:"AssetStore"`
	AccessKey   router.Processor `preprocessor:"accesskey"`
	DBConn      router.Processor `preprocessor:"dbconn"`
	PluginReady router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

AssetUploadHandler models the handler for asset upload request

func (*AssetUploadHandler) GetPreprocessors

func (h *AssetUploadHandler) GetPreprocessors() []router.Processor

GetPreprocessors returns all pre-processors for the handler

func (*AssetUploadHandler) Handle

func (h *AssetUploadHandler) Handle(
	payload *router.Payload,
	response *router.Response,
)

Handle is the handling method of the asset upload request

func (*AssetUploadHandler) Setup

func (h *AssetUploadHandler) Setup()

Setup adds injected pre-processors to preprocessors array

type AssetUploadResponse

type AssetUploadResponse struct {
	PostRequest *skyAsset.PostFileRequest `json:"post-request"`
	Asset       *map[string]interface{}   `json:"asset"`
}

AssetUploadResponse models the response of asset upload request

type AuthResponse

type AuthResponse struct {
	UserID      string              `json:"user_id,omitempty"`
	Profile     *skyconv.JSONRecord `json:"profile"`
	Roles       []string            `json:"roles,omitempty"`
	AccessToken string              `json:"access_token,omitempty"`
	LastLoginAt *time.Time          `json:"last_login_at,omitempty"`
	LastSeenAt  *time.Time          `json:"last_seen_at,omitempty"`
}

AuthResponse is the unify way of returing a AuthInfo with AuthData to SDK

type AuthResponseFactory added in v1.1.0

type AuthResponseFactory struct {
	Conn       skydb.Conn
	Database   skydb.Database
	AssetStore asset.Store
}

func (AuthResponseFactory) NewAuthResponse added in v1.1.0

func (f AuthResponseFactory) NewAuthResponse(info skydb.AuthInfo, user skydb.Record, accessToken string, hasMasterKey bool) (AuthResponse, error)

type ChangePasswordHandler added in v1.4.0

type ChangePasswordHandler struct {
	TokenStore      authtoken.Store        `inject:"TokenStore"`
	AssetStore      asset.Store            `inject:"AssetStore"`
	PasswordChecker *audit.PasswordChecker `inject:"PasswordChecker"`
	PwHousekeeper   *audit.PwHousekeeper   `inject:"PwHousekeeper"`
	Authenticator   router.Processor       `preprocessor:"authenticator"`
	DBConn          router.Processor       `preprocessor:"dbconn"`
	InjectPublicDB  router.Processor       `preprocessor:"inject_public_db"`
	InjectAuth      router.Processor       `preprocessor:"require_auth_skip_pwexpiry"`
	InjectUser      router.Processor       `preprocessor:"require_user"`
	PluginReady     router.Processor       `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

ChangePasswordHandler change the current user password

ChangePasswordHandler receives three parameters:

* old_password (string, required) * password (string, required)

If user is not logged in, an 404 not found will return.

Current implementation
curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "auth:password",
    "old_password": "rick.mak@gmail.com",
    "password": "123456"
}
EOF

Response return existing access toektn if not invalidate

TODO: Input accept `user_id` and `invalidate`. If `user_id` is supplied, will check authorization policy and see if existing accept `invalidate` and invaldate all existing access token. Return authInfoID with new AccessToken if the invalidate is true

func (*ChangePasswordHandler) GetPreprocessors added in v1.4.0

func (h *ChangePasswordHandler) GetPreprocessors() []router.Processor

func (*ChangePasswordHandler) Handle added in v1.4.0

func (h *ChangePasswordHandler) Handle(payload *router.Payload, response *router.Response)

func (*ChangePasswordHandler) Setup added in v1.4.0

func (h *ChangePasswordHandler) Setup()

type DeviceRegisterHandler

type DeviceRegisterHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"require_auth"`
	InjectDB      router.Processor `preprocessor:"inject_db"`
	CheckUser     router.Processor `preprocessor:"check_user"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

DeviceRegisterHandler creates or updates a device and associates it to a user

Example to create a new device:

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
	"action": "device:register",
	"access_token": "some-access-token",
	"type": "ios",
	"topic": "io.skygear.sample.topic",
	"device_token": "some-device-token"
}
EOF

Example to update an existing device:

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
	"action": "device:register",
	"access_token": "some-access-token",
	"id": "existing-device-id",
	"type": "ios",
	"device_token": "new-device-token"
}
EOF

func (*DeviceRegisterHandler) GetPreprocessors

func (h *DeviceRegisterHandler) GetPreprocessors() []router.Processor

func (*DeviceRegisterHandler) Handle

func (h *DeviceRegisterHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*DeviceRegisterHandler) Setup

func (h *DeviceRegisterHandler) Setup()

type DeviceReigsterResult

type DeviceReigsterResult struct {
	ID string `json:"id"`
}

DeviceReigsterResult is the result put onto response.Result on successful call of DeviceRegisterHandler

type DeviceUnregisterHandler added in v0.20.0

type DeviceUnregisterHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"require_auth"`
	InjectDB      router.Processor `preprocessor:"inject_db"`
	CheckUser     router.Processor `preprocessor:"check_user"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

DeviceUnregisterHandler removes user id from a device

Example to unregister a device:

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
	"action": "device:unregister",
	"access_token": "some-access-token",
	"type": "ios",
	"device_token": "some-device-token"
}
EOF

func (*DeviceUnregisterHandler) GetPreprocessors added in v0.20.0

func (h *DeviceUnregisterHandler) GetPreprocessors() []router.Processor

func (*DeviceUnregisterHandler) Handle added in v0.20.0

func (h *DeviceUnregisterHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*DeviceUnregisterHandler) Setup added in v0.20.0

func (h *DeviceUnregisterHandler) Setup()

type ExpressionACLChecker added in v1.1.0

type ExpressionACLChecker struct {
	FieldACL   skydb.FieldACL
	RecordType string
	AuthInfo   *skydb.AuthInfo
	Database   skydb.Database
}

func (*ExpressionACLChecker) Check added in v1.1.0

type GetFileHandler

type GetFileHandler struct {
	AssetStore skyAsset.Store   `inject:"AssetStore"`
	DBConn     router.Processor `preprocessor:"dbconn"`
	// contains filtered or unexported fields
}

GetFileHandler models the handler for getting asset file

func (*GetFileHandler) GetPreprocessors

func (h *GetFileHandler) GetPreprocessors() []router.Processor

GetPreprocessors returns all preprocessors

func (*GetFileHandler) Handle

func (h *GetFileHandler) Handle(payload *router.Payload, response *router.Response)

Handle handles the get request for asset file

func (*GetFileHandler) Setup

func (h *GetFileHandler) Setup()

Setup sets preprocessors being used

type HealthzHandler added in v0.21.1

type HealthzHandler struct {
	PluginReady router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

func (*HealthzHandler) GetPreprocessors added in v0.21.1

func (h *HealthzHandler) GetPreprocessors() []router.Processor

func (*HealthzHandler) Handle added in v0.21.1

func (h *HealthzHandler) Handle(playload *router.Payload, response *router.Response)

func (*HealthzHandler) Setup added in v0.21.1

func (h *HealthzHandler) Setup()

type HomeHandler

type HomeHandler struct {
}

HomeHandler temp landing. FIXME

func (*HomeHandler) GetPreprocessors

func (h *HomeHandler) GetPreprocessors() []router.Processor

func (*HomeHandler) Handle

func (h *HomeHandler) Handle(playload *router.Payload, response *router.Response)

func (*HomeHandler) Setup

func (h *HomeHandler) Setup()

type LinkProviderHandler added in v1.2.0

type LinkProviderHandler struct {
	HookRegistry     *hook.Registry   `inject:"HookRegistry"`
	AssetStore       asset.Store      `inject:"AssetStore"`
	AuthRecordKeys   [][]string       `inject:"AuthRecordKeys"`
	AccessKey        router.Processor `preprocessor:"accesskey"`
	DBConn           router.Processor `preprocessor:"dbconn"`
	InjectPublicDB   router.Processor `preprocessor:"inject_public_db"`
	PluginReady      router.Processor `preprocessor:"plugin_ready"`
	RequireMasterKey router.Processor `preprocessor:"require_master_key"`
	// contains filtered or unexported fields
}

LinkProviderHandler connect user with provider information

LinkProviderHandler receives parameters:

* provider (string, required) * principal_id (string, required) * user_id (string, required) * token_response (json object, optional) * provider_profile (json object, optional)

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
		"action": "sso:oauth:link",
		"provider": "facebook",
		"principal_id": "104174434987489953648",
		"user_id": "c0959b6b-15ea-4e21-8afb-9c8308ad79db",
		"token_response": {
			"access_token": "access_token"
		},
		"provider_profile": {
			"id": "104174434987489953648",
			"email": "chima@skygeario.com"
		}
}

EOF Response

{
    "result": "OK"
}

func (*LinkProviderHandler) GetPreprocessors added in v1.2.0

func (h *LinkProviderHandler) GetPreprocessors() []router.Processor

func (*LinkProviderHandler) Handle added in v1.2.0

func (h *LinkProviderHandler) Handle(payload *router.Payload, response *router.Response)

func (*LinkProviderHandler) Setup added in v1.2.0

func (h *LinkProviderHandler) Setup()

type LoginHandler

type LoginHandler struct {
	TokenStore       authtoken.Store    `inject:"TokenStore"`
	ProviderRegistry *provider.Registry `inject:"ProviderRegistry"`
	HookRegistry     *hook.Registry     `inject:"HookRegistry"`
	AssetStore       asset.Store        `inject:"AssetStore"`
	AuthRecordKeys   [][]string         `inject:"AuthRecordKeys"`
	AccessKey        router.Processor   `preprocessor:"accesskey"`
	DBConn           router.Processor   `preprocessor:"dbconn"`
	InjectPublicDB   router.Processor   `preprocessor:"inject_public_db"`
	PluginReady      router.Processor   `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

LoginHandler authenticate user with password

The user can be either identified by username or password.

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "auth:login",
    "auth_data": {
      "username": "rickmak",
      "email": "rick.mak@gmail.com",
    },
    "password": "123456"
}

EOF

func (*LoginHandler) GetPreprocessors

func (h *LoginHandler) GetPreprocessors() []router.Processor

func (*LoginHandler) Handle

func (h *LoginHandler) Handle(payload *router.Payload, response *router.Response)

func (*LoginHandler) Setup

func (h *LoginHandler) Setup()

type LoginProviderHandler added in v1.2.0

type LoginProviderHandler struct {
	TokenStore       authtoken.Store    `inject:"TokenStore"`
	ProviderRegistry *provider.Registry `inject:"ProviderRegistry"`
	HookRegistry     *hook.Registry     `inject:"HookRegistry"`
	AssetStore       asset.Store        `inject:"AssetStore"`
	AuthRecordKeys   [][]string         `inject:"AuthRecordKeys"`
	AccessKey        router.Processor   `preprocessor:"accesskey"`
	DBConn           router.Processor   `preprocessor:"dbconn"`
	InjectPublicDB   router.Processor   `preprocessor:"inject_public_db"`
	PluginReady      router.Processor   `preprocessor:"plugin_ready"`
	RequireMasterKey router.Processor   `preprocessor:"require_master_key"`
	// contains filtered or unexported fields
}

func (*LoginProviderHandler) GetPreprocessors added in v1.2.0

func (h *LoginProviderHandler) GetPreprocessors() []router.Processor

func (*LoginProviderHandler) Handle added in v1.2.0

func (h *LoginProviderHandler) Handle(payload *router.Payload, response *router.Response)

func (*LoginProviderHandler) Setup added in v1.2.0

func (h *LoginProviderHandler) Setup()

type LogoutHandler

type LogoutHandler struct {
	TokenStore    authtoken.Store  `inject:"TokenStore"`
	Authenticator router.Processor `preprocessor:"authenticator"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

LogoutHandler receives an access token and invalidates it

func (*LogoutHandler) GetPreprocessors

func (h *LogoutHandler) GetPreprocessors() []router.Processor

func (*LogoutHandler) Handle

func (h *LogoutHandler) Handle(payload *router.Payload, response *router.Response)

func (*LogoutHandler) Setup

func (h *LogoutHandler) Setup()

type MeHandler

type MeHandler struct {
	TokenStore     authtoken.Store  `inject:"TokenStore"`
	AssetStore     asset.Store      `inject:"AssetStore"`
	Authenticator  router.Processor `preprocessor:"authenticator"`
	DBConn         router.Processor `preprocessor:"dbconn"`
	InjectAuth     router.Processor `preprocessor:"require_auth"`
	InjectUser     router.Processor `preprocessor:"require_user"`
	InjectPublicDB router.Processor `preprocessor:"inject_public_db"`
	PluginReady    router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

MeHandler handles the me request

func (*MeHandler) GetPreprocessors

func (h *MeHandler) GetPreprocessors() []router.Processor

GetPreprocessors returns all pre-processors for the handler

func (*MeHandler) Handle

func (h *MeHandler) Handle(payload *router.Payload, response *router.Response)

Handle is the handling method of the me request

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "me"
}
EOF
{
  "user_id": "3df4b52b-bd58-4fa2-8aee-3d44fd7f974d",
  "username": "user1",
  "last_login_at": "2016-09-08T06:42:59.871181Z",
  "last_seen_at": "2016-09-08T07:15:18.026567355Z",
  "roles": []
}

func (*MeHandler) Setup

func (h *MeHandler) Setup()

Setup adds injected pre-processors to preprocessors array

type PubSubHandler

type PubSubHandler struct {
	WebSocket *pubsub.WsPubSub
	AccessKey router.Processor `preprocessor:"accesskey"`
	// contains filtered or unexported fields
}

func (*PubSubHandler) GetPreprocessors

func (h *PubSubHandler) GetPreprocessors() []router.Processor

func (*PubSubHandler) Handle

func (h *PubSubHandler) Handle(payload *router.Payload, response *router.Response)

func (*PubSubHandler) Setup

func (h *PubSubHandler) Setup()

type PushToDeviceHandler

type PushToDeviceHandler struct {
	NotificationSender push.Sender      `inject:"PushSender"`
	AccessKey          router.Processor `preprocessor:"accesskey"`
	DBConn             router.Processor `preprocessor:"dbconn"`
	InjectDB           router.Processor `preprocessor:"inject_db"`
	Notification       router.Processor `preprocessor:"notification"`
	PluginReady        router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

func (*PushToDeviceHandler) GetPreprocessors

func (h *PushToDeviceHandler) GetPreprocessors() []router.Processor

func (*PushToDeviceHandler) Handle

func (h *PushToDeviceHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*PushToDeviceHandler) Setup

func (h *PushToDeviceHandler) Setup()

type PushToUserHandler

type PushToUserHandler struct {
	NotificationSender push.Sender      `inject:"PushSender"`
	AccessKey          router.Processor `preprocessor:"accesskey"`
	DBConn             router.Processor `preprocessor:"dbconn"`
	InjectDB           router.Processor `preprocessor:"inject_db"`
	Notification       router.Processor `preprocessor:"notification"`
	PluginReady        router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

func (*PushToUserHandler) GetPreprocessors

func (h *PushToUserHandler) GetPreprocessors() []router.Processor

func (*PushToUserHandler) Handle

func (h *PushToUserHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*PushToUserHandler) Setup

func (h *PushToUserHandler) Setup()

type QueryParser

type QueryParser struct {
	UserID string
}

QueryParser is a context for parsing raw query to skydb.Query

type RecordDeleteHandler

type RecordDeleteHandler struct {
	HookRegistry  *hook.Registry    `inject:"HookRegistry"`
	AccessModel   skydb.AccessModel `inject:"AccessModel"`
	Authenticator router.Processor  `preprocessor:"authenticator"`
	DBConn        router.Processor  `preprocessor:"dbconn"`
	InjectAuth    router.Processor  `preprocessor:"require_auth"`
	InjectDB      router.Processor  `preprocessor:"inject_db"`
	CheckUser     router.Processor  `preprocessor:"check_user"`
	PluginReady   router.Processor  `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RecordDeleteHandler is dummy implementation on delete Records

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "record:delete",
    "access_token": "validToken",
    "database_id": "_private",
    "ids": ["note/EA6A3E68-90F3-49B5-B470-5FFDB7A0D4E8"]
}

EOF

func (*RecordDeleteHandler) GetPreprocessors

func (h *RecordDeleteHandler) GetPreprocessors() []router.Processor

func (*RecordDeleteHandler) Handle

func (h *RecordDeleteHandler) Handle(payload *router.Payload, response *router.Response)

func (*RecordDeleteHandler) Setup

func (h *RecordDeleteHandler) Setup()

type RecordFetchHandler

type RecordFetchHandler struct {
	AssetStore    asset.Store       `inject:"AssetStore"`
	AccessModel   skydb.AccessModel `inject:"AccessModel"`
	Authenticator router.Processor  `preprocessor:"authenticator"`
	DBConn        router.Processor  `preprocessor:"dbconn"`
	InjectAuth    router.Processor  `preprocessor:"inject_auth"`
	InjectDB      router.Processor  `preprocessor:"inject_db"`
	CheckUser     router.Processor  `preprocessor:"check_user"`
	PluginReady   router.Processor  `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RecordFetchHandler is dummy implementation on fetching Records

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "record:fetch",
    "access_token": "validToken",
    "database_id": "_private",
    "ids": ["note/1004", "note/1005"]
}

EOF

func (*RecordFetchHandler) GetPreprocessors

func (h *RecordFetchHandler) GetPreprocessors() []router.Processor

func (*RecordFetchHandler) Handle

func (h *RecordFetchHandler) Handle(payload *router.Payload, response *router.Response)

func (*RecordFetchHandler) Setup

func (h *RecordFetchHandler) Setup()

type RecordQueryHandler

type RecordQueryHandler struct {
	AssetStore    asset.Store       `inject:"AssetStore"`
	AccessModel   skydb.AccessModel `inject:"AccessModel"`
	Authenticator router.Processor  `preprocessor:"authenticator"`
	DBConn        router.Processor  `preprocessor:"dbconn"`
	InjectAuth    router.Processor  `preprocessor:"inject_auth"`
	InjectDB      router.Processor  `preprocessor:"inject_db"`
	CheckUser     router.Processor  `preprocessor:"check_user"`
	PluginReady   router.Processor  `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RecordQueryHandler is dummy implementation on fetching Records

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "record:query",
    "access_token": "validToken",
    "database_id": "_private",
    "record_type": "note",
    "sort": [
        [{"$val": "noteOrder", "$type": "desc"}, "asc"]
    ]
}

EOF

func (*RecordQueryHandler) GetPreprocessors

func (h *RecordQueryHandler) GetPreprocessors() []router.Processor

func (*RecordQueryHandler) Handle

func (h *RecordQueryHandler) Handle(payload *router.Payload, response *router.Response)

func (*RecordQueryHandler) Setup

func (h *RecordQueryHandler) Setup()

type RecordSaveHandler

type RecordSaveHandler struct {
	HookRegistry   *hook.Registry     `inject:"HookRegistry"`
	AssetStore     asset.Store        `inject:"AssetStore"`
	AccessModel    skydb.AccessModel  `inject:"AccessModel"`
	EventSender    pluginEvent.Sender `inject:"PluginEventSender"`
	AuthRecordKeys [][]string         `inject:"AuthRecordKeys"`
	Authenticator  router.Processor   `preprocessor:"authenticator"`
	DBConn         router.Processor   `preprocessor:"dbconn"`
	InjectAuth     router.Processor   `preprocessor:"require_auth"`
	InjectDB       router.Processor   `preprocessor:"inject_db"`
	CheckUser      router.Processor   `preprocessor:"check_user"`
	PluginReady    router.Processor   `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RecordSaveHandler is dummy implementation on save/modify Records

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "record:save",
    "access_token": "validToken",
    "database_id": "_public",
    "records": [{
        "_id": "note/EA6A3E68-90F3-49B5-B470-5FFDB7A0D4E8",
        "content": "ewdsa",
        "_access": [{
            "role": "admin",
            "level": "write"
        }]
    }]
}

EOF

Save with reference

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
  "action": "record:save",
  "database_id": "_public",
  "access_token": "986bee3b-8dd9-45c2-b40c-8b6ef274cf12",
  "records": [
    {
      "collection": {
        "$type": "ref",
        "$id": "collection/10"
      },
      "noteOrder": 1,
      "content": "hi",
      "_id": "note/71BAE736-E9C5-43CB-ADD1-D8633B80CAFA",
      "_type": "record",
      "_access": [{
          "role": "admin",
          "level": "write"
      }]
    }
  ]
}

EOF

func (*RecordSaveHandler) GetPreprocessors

func (h *RecordSaveHandler) GetPreprocessors() []router.Processor

func (*RecordSaveHandler) Handle

func (h *RecordSaveHandler) Handle(payload *router.Payload, response *router.Response)

func (*RecordSaveHandler) Setup

func (h *RecordSaveHandler) Setup()

type RelationAddHandler

type RelationAddHandler struct {
	AssetStore    asset.Store      `inject:"AssetStore"`
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"inject_auth"`
	InjectDB      router.Processor `preprocessor:"inject_db"`
	CheckUser     router.Processor `preprocessor:"check_user"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RelationAddHandler add current user relation

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "relation:add",
    "access_token": "ACCESS_TOKEN",
    "name": "follow",
    "targets": [
        "1001",
        "1002"
    ]
}

EOF

{
    "request_id": "REQUEST_ID",
    "result": [
        {
            "id": "1001",
            "type": "user",
            "data": {
                "_type": "record",
                "_id": "1001",
                "_access": null,
                "username": "user1001",
                "email": "user1001@skygear.io"
            }
        },
        {
            "id": "1002",
            "type": "error",
            "data": {
                "type": "ResourceFetchFailure",
                "code": 101,
                "message": "failed to fetch user id = 1002"
            }
        }
    ]
}

func (*RelationAddHandler) GetPreprocessors

func (h *RelationAddHandler) GetPreprocessors() []router.Processor

func (*RelationAddHandler) Handle

func (h *RelationAddHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*RelationAddHandler) Setup

func (h *RelationAddHandler) Setup()

type RelationQueryHandler

type RelationQueryHandler struct {
	AssetStore    asset.Store      `inject:"AssetStore"`
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"inject_auth"`
	InjectDB      router.Processor `preprocessor:"inject_db"`
	CheckUser     router.Processor `preprocessor:"check_user"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RelationQueryHandler query user from current users' relation

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "relation:query",
    "access_token": "ACCESS_TOKEN",
    "name": "follow",
    "direction": "outward"
	   "limit": 2
	   "offset": 0
}

EOF

{
    "request_id": "REQUEST_ID",
    "result": [
        {
            "id": "1001",
            "type": "user",
            "data": {
                "_type": "record",
                "_id": "user/1001",
                "_access": null,
                "username": "user1001",
                "email": "user1001@skygear.io"
            }
        },
        {
            "id": "1002",
            "type": "user",
            "data": {
                "_type": "record",
                "_id": "1002",
                "_access": null,
                "username": "user1002",
                "email": "user1001@skygear.io"
            }
        }
    ],
    "info": {
        "count": 2
    }
}

func (*RelationQueryHandler) GetPreprocessors

func (h *RelationQueryHandler) GetPreprocessors() []router.Processor

func (*RelationQueryHandler) Handle

func (h *RelationQueryHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*RelationQueryHandler) Setup

func (h *RelationQueryHandler) Setup()

type RelationRemoveHandler

type RelationRemoveHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"inject_auth"`
	InjectDB      router.Processor `preprocessor:"inject_db"`
	CheckUser     router.Processor `preprocessor:"check_user"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RelationRemoveHandler remove a users' relation to other users

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "relation:remove",
    "access_token": "ACCESS_TOKEN",
    "name": "follow",
    "targets": [
        "1001",
        "1002"
    ]
}

EOF

func (*RelationRemoveHandler) GetPreprocessors

func (h *RelationRemoveHandler) GetPreprocessors() []router.Processor

func (*RelationRemoveHandler) Handle

func (h *RelationRemoveHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*RelationRemoveHandler) Setup

func (h *RelationRemoveHandler) Setup()

type ResetPasswordHandler added in v1.4.0

type ResetPasswordHandler struct {
	TokenStore       authtoken.Store        `inject:"TokenStore"`
	AssetStore       asset.Store            `inject:"AssetStore"`
	PasswordChecker  *audit.PasswordChecker `inject:"PasswordChecker"`
	PwHousekeeper    *audit.PwHousekeeper   `inject:"PwHousekeeper"`
	AccessKey        router.Processor       `preprocessor:"accesskey"`
	DBConn           router.Processor       `preprocessor:"dbconn"`
	InjectPublicDB   router.Processor       `preprocessor:"inject_public_db"`
	PluginReady      router.Processor       `preprocessor:"plugin_ready"`
	RequireMasterKey router.Processor       `preprocessor:"require_master_key"`
	// contains filtered or unexported fields
}

ResetPasswordHandler resets the current user password

ResetPasswordHandler receives two parameter:

* auth_id (string, required) * password (string, required)

If user is not logged in, an 404 not found will return.

Current implementation
curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "auth:reset_password",
    "auth_id": "some-id",
    "password": "123456"
}
EOF

Response return existing access token if not invalidate

func (*ResetPasswordHandler) GetPreprocessors added in v1.4.0

func (h *ResetPasswordHandler) GetPreprocessors() []router.Processor

func (*ResetPasswordHandler) Handle added in v1.4.0

func (h *ResetPasswordHandler) Handle(payload *router.Payload, response *router.Response)

func (*ResetPasswordHandler) Setup added in v1.4.0

func (h *ResetPasswordHandler) Setup()

type RoleAdminHandler

type RoleAdminHandler struct {
	AccessKey   router.Processor `preprocessor:"accesskey"`
	DevOnly     router.Processor `preprocessor:"dev_only"`
	DBConn      router.Processor `preprocessor:"dbconn"`
	PluginReady router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RoleAdminHandler enable system administrator to set which roles can perform administrative action, like change others user role.

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "role:default",
    "master_key": "MASTER_KEY",
    "access_token": "ACCESS_TOKEN",
    "roles": [
       "admin",
       "moderator"
    ]
}

EOF

{
    "result": [
       "admin",
       "moderator"
    ]
}

func (*RoleAdminHandler) GetPreprocessors

func (h *RoleAdminHandler) GetPreprocessors() []router.Processor

func (*RoleAdminHandler) Handle

func (h *RoleAdminHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*RoleAdminHandler) Setup

func (h *RoleAdminHandler) Setup()

type RoleAssignHandler added in v1.1.0

type RoleAssignHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"inject_auth"`
	RequireAdmin  router.Processor `preprocessor:"require_admin"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RoleAssignHandler allow system administractor to batch assign roles to users

RoleAssignHandler required user with admin role. All specified users will assign to all roles specified. Roles not already exisited in DB will be created. Users not already existed will be ignored.

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "role:assign",
    "master_key": "MASTER_KEY",
    "access_token": "ACCESS_TOKEN",
    "roles": [
       "writer",
       "user"
    ],
    "users": [
       "95db1e34-0cc0-47b0-8a97-3948633ce09f",
       "3df4b52b-bd58-4fa2-8aee-3d44fd7f974d"
    ]
}

EOF

{
    "result": "OK"
}

func (*RoleAssignHandler) GetPreprocessors added in v1.1.0

func (h *RoleAssignHandler) GetPreprocessors() []router.Processor

func (*RoleAssignHandler) Handle added in v1.1.0

func (h *RoleAssignHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*RoleAssignHandler) Setup added in v1.1.0

func (h *RoleAssignHandler) Setup()

type RoleDefaultHandler

type RoleDefaultHandler struct {
	AccessKey   router.Processor `preprocessor:"accesskey"`
	DevOnly     router.Processor `preprocessor:"dev_only"`
	DBConn      router.Processor `preprocessor:"dbconn"`
	PluginReady router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RoleDefaultHandler enable system administrator to set default user role

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "role:default",
    "master_key": "MASTER_KEY",
    "access_token": "ACCESS_TOKEN",
    "roles": [
       "writer",
       "user"
    ]
}

EOF

{
    "result": [
       "writer",
       "user"
    ]
}

func (*RoleDefaultHandler) GetPreprocessors

func (h *RoleDefaultHandler) GetPreprocessors() []router.Processor

func (*RoleDefaultHandler) Handle

func (h *RoleDefaultHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*RoleDefaultHandler) Setup

func (h *RoleDefaultHandler) Setup()

type RoleGetHandler added in v1.1.0

type RoleGetHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"inject_auth"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RoleGetHandler returns roles of users specified by user IDs. Users can only get his own roles except that administrators can query roles of other users.

curl \
  -X POST \
  -H "Content-Type: application/json" \
  -d @- \
  http://localhost:3000/ \

<<EOF

{
    "action": "role:get",
    "master_key": "MASTER_KEY",
    "access_token": "ACCESS_TOKEN",
    "users": [
       "e0cfd2d6-184d-4dad-8cf1-f7ff96954c8d",
       "e023c399-f329-41d6-9d95-9a5261c63501",
       "24e1df68-9007-4111-8ec1-c53a2a45ad9e"
    ]
}

EOF

{
    "result": {
        "e0cfd2d6-184d-4dad-8cf1-f7ff96954c8d": [
            "developer",
            "tech-lead"
        ],
        "e023c399-f329-41d6-9d95-9a5261c63501": [
        ],
        "24e1df68-9007-4111-8ec1-c53a2a45ad9e": [
            "project-manager",
            "project-consultant"
        ]
    }
}

func (*RoleGetHandler) GetPreprocessors added in v1.1.0

func (h *RoleGetHandler) GetPreprocessors() []router.Processor

func (*RoleGetHandler) Handle added in v1.1.0

func (h *RoleGetHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*RoleGetHandler) Setup added in v1.1.0

func (h *RoleGetHandler) Setup()

type RoleRevokeHandler added in v1.1.0

type RoleRevokeHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"inject_auth"`
	RequireAdmin  router.Processor `preprocessor:"require_admin"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

RoleRevokeHandler allow system administractor to batch revoke roles from users

RoleRevokeHandler required user with admin role. All specified users will have all specified roles revoked. Roles or users not already exisited in DB will be ignored.

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "role:revoke",
    "master_key": "MASTER_KEY",
    "access_token": "ACCESS_TOKEN",
    "roles": [
       "writer",
       "user"
    ],
    "users": [
       "95db1e34-0cc0-47b0-8a97-3948633ce09f",
       "3df4b52b-bd58-4fa2-8aee-3d44fd7f974d"
    ]
}

EOF

{
    "result": "OK"
}

func (*RoleRevokeHandler) GetPreprocessors added in v1.1.0

func (h *RoleRevokeHandler) GetPreprocessors() []router.Processor

func (*RoleRevokeHandler) Handle added in v1.1.0

func (h *RoleRevokeHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*RoleRevokeHandler) Setup added in v1.1.0

func (h *RoleRevokeHandler) Setup()

type SSOCustomTokenLoginHandler added in v1.3.0

type SSOCustomTokenLoginHandler struct {
	CustomTokenSecret string

	TokenStore       authtoken.Store    `inject:"TokenStore"`
	ProviderRegistry *provider.Registry `inject:"ProviderRegistry"`
	HookRegistry     *hook.Registry     `inject:"HookRegistry"`
	AssetStore       asset.Store        `inject:"AssetStore"`
	AuthRecordKeys   [][]string         `inject:"AuthRecordKeys"`
	AccessKey        router.Processor   `preprocessor:"accesskey"`
	DBConn           router.Processor   `preprocessor:"dbconn"`
	InjectPublicDB   router.Processor   `preprocessor:"inject_public_db"`
	PluginReady      router.Processor   `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SSOCustomTokenLoginHandler authenticates the user with a custom token

An external server is responsible for generating the custom token which contains a Principal ID and a signature. It is required that the token has issued-at and expired-at claims.

The custom token is signed by a shared secret and encoded in JWT format.

The claims of the custom token is as follows:

{
  "sub": "id1234567800",
  "iat": 1513316033,
  "exp": 1828676033,
  "skyprofile": {
    "name": "John Doe"
  }
}

When signing the above claims with the custom token secret `ssosecret` using HS256 as algorithm, the following JWT token is produced:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJpZDEyMzQ1Njc4MDAiLCJpYXQiOjE1MTMzMTYwMzMsImV4cCI6MTgyODY3NjAzMywic2t5cHJvZmlsZSI6eyJuYW1lIjoiSm9obiBEb2UifX0.JRAwXPF4CDWCpMCvemCBPrUAQAXPV9qVWeAYo1vBAqQ

This token can be used to log in to Skygear Server. If there is no user associated with the Principal ID (the subject/sub claim), a new user is created.

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
	"action": "sso:custom_token:login",
	"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJpZDEyMzQ1Njc4MDAiLCJpYXQiOjE1MTMzMTYwMzMsImV4cCI6MTgyODY3NjAzMywic2t5cHJvZmlsZSI6eyJuYW1lIjoiSm9obiBEb2UifX0.JRAwXPF4CDWCpMCvemCBPrUAQAXPV9qVWeAYo1vBAqQ"
}

EOF

func (*SSOCustomTokenLoginHandler) GetPreprocessors added in v1.3.0

func (h *SSOCustomTokenLoginHandler) GetPreprocessors() []router.Processor

func (*SSOCustomTokenLoginHandler) Handle added in v1.3.0

func (h *SSOCustomTokenLoginHandler) Handle(payload *router.Payload, response *router.Response)

func (*SSOCustomTokenLoginHandler) Setup added in v1.3.0

func (h *SSOCustomTokenLoginHandler) Setup()

type SchemaAccessHandler

type SchemaAccessHandler struct {
	AccessKey   router.Processor `preprocessor:"accesskey"`
	DevOnly     router.Processor `preprocessor:"dev_only"`
	DBConn      router.Processor `preprocessor:"dbconn"`
	InjectDB    router.Processor `preprocessor:"inject_db"`
	PluginReady router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SchemaAccessHandler handles the update of creation access of record

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/schema/access <<EOF
{
	"master_key": "MASTER_KEY",
	"action": "schema:access",
	"type": "note",
	"create_roles": [
		"admin",
		"writer"
	]
}

EOF

func (*SchemaAccessHandler) GetPreprocessors

func (h *SchemaAccessHandler) GetPreprocessors() []router.Processor

func (*SchemaAccessHandler) Handle

func (h *SchemaAccessHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SchemaAccessHandler) Setup

func (h *SchemaAccessHandler) Setup()

type SchemaCreateHandler

type SchemaCreateHandler struct {
	EventSender pluginEvent.Sender `inject:"PluginEventSender"`
	AccessKey   router.Processor   `preprocessor:"accesskey"`
	DevOnly     router.Processor   `preprocessor:"dev_only"`
	DBConn      router.Processor   `preprocessor:"dbconn"`
	InjectDB    router.Processor   `preprocessor:"inject_db"`
	PluginReady router.Processor   `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SchemaCreateHandler handles the action of creating new columns

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/schema/create <<EOF
{
	"master_key": "MASTER_KEY",
	"action": "schema:create",
	"record_types":{
		"student": {
			"fields":[
				{"name": "age", "type": "number"},
				{"name": "nickname" "type": "string"}
			]
		}
	}
}

EOF

func (*SchemaCreateHandler) GetPreprocessors

func (h *SchemaCreateHandler) GetPreprocessors() []router.Processor

func (*SchemaCreateHandler) Handle

func (h *SchemaCreateHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SchemaCreateHandler) Setup

func (h *SchemaCreateHandler) Setup()

type SchemaDefaultAccessHandler added in v0.23.0

type SchemaDefaultAccessHandler struct {
	AccessKey   router.Processor `preprocessor:"accesskey"`
	DevOnly     router.Processor `preprocessor:"dev_only"`
	DBConn      router.Processor `preprocessor:"dbconn"`
	InjectDB    router.Processor `preprocessor:"inject_db"`
	PluginReady router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SchemaDefaultAccessHandler handles the update of creation access of record

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/schema/default_access <<EOF
{
	"master_key": "MASTER_KEY",
	"action": "schema:default_access",
	"type": "note",
	"default_access": [
		{"public": true, "level": "write"}
	]
}

EOF

func (*SchemaDefaultAccessHandler) GetPreprocessors added in v0.23.0

func (h *SchemaDefaultAccessHandler) GetPreprocessors() []router.Processor

func (*SchemaDefaultAccessHandler) Handle added in v0.23.0

func (h *SchemaDefaultAccessHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SchemaDefaultAccessHandler) Setup added in v0.23.0

func (h *SchemaDefaultAccessHandler) Setup()

type SchemaDeleteHandler

type SchemaDeleteHandler struct {
	EventSender pluginEvent.Sender `inject:"PluginEventSender"`
	AccessKey   router.Processor   `preprocessor:"accesskey"`
	DevOnly     router.Processor   `preprocessor:"dev_only"`
	DBConn      router.Processor   `preprocessor:"dbconn"`
	InjectDB    router.Processor   `preprocessor:"inject_db"`
	PluginReady router.Processor   `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SchemaDeleteHandler handles the action of deleting column

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/schema/delete <<EOF
{
	"master_key": "MASTER_KEY",
	"action": "schema:delete",
	"record_type": "student",
	"item_name": "score"
}

EOF

func (*SchemaDeleteHandler) GetPreprocessors

func (h *SchemaDeleteHandler) GetPreprocessors() []router.Processor

func (*SchemaDeleteHandler) Handle

func (h *SchemaDeleteHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SchemaDeleteHandler) Setup

func (h *SchemaDeleteHandler) Setup()

type SchemaFetchHandler

type SchemaFetchHandler struct {
	AccessKey   router.Processor `preprocessor:"accesskey"`
	DevOnly     router.Processor `preprocessor:"dev_only"`
	DBConn      router.Processor `preprocessor:"dbconn"`
	InjectDB    router.Processor `preprocessor:"inject_db"`
	PluginReady router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SchemaFetchHandler handles the action of returing information of record schema

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/schema/fetch <<EOF
{
	"master_key": "MASTER_KEY",
	"action": "schema:fetch"
}

EOF

func (*SchemaFetchHandler) GetPreprocessors

func (h *SchemaFetchHandler) GetPreprocessors() []router.Processor

func (*SchemaFetchHandler) Handle

func (h *SchemaFetchHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SchemaFetchHandler) Setup

func (h *SchemaFetchHandler) Setup()

type SchemaFieldAccessGetHandler added in v1.1.0

type SchemaFieldAccessGetHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"inject_auth"`
	RequireAdmin  router.Processor `preprocessor:"require_admin"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SchemaFieldAccessGetHandler fetches the entire Field ACL settings.

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/schema/default_access <<EOF
{
	"api_key": "MASTER_KEY",
	"action": "schema:field_access:get",
}
{
  "result": [
    {
      "record_type": "User",
      "record_field": "*",
      "user_role": "_owner",
      "writable": true,
      "readable": true,
      "comparable": true,
      "discoverable": true
    }
  ]
}

EOF

func (*SchemaFieldAccessGetHandler) GetPreprocessors added in v1.1.0

func (h *SchemaFieldAccessGetHandler) GetPreprocessors() []router.Processor

func (*SchemaFieldAccessGetHandler) Handle added in v1.1.0

func (h *SchemaFieldAccessGetHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SchemaFieldAccessGetHandler) Setup added in v1.1.0

func (h *SchemaFieldAccessGetHandler) Setup()

type SchemaFieldAccessUpdateHandler added in v1.1.0

type SchemaFieldAccessUpdateHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"inject_auth"`
	RequireAdmin  router.Processor `preprocessor:"require_admin"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SchemaFieldAccessUpdateHandler fetches the entire Field ACL settings.

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/schema/default_access <<EOF
{
	"api_key": "MASTER_KEY",
	"action": "schema:field_access:get",
}
{
  "result": [
    {
      "record_type": "User",
      "record_field": "*",
      "user_role": "_owner",
      "writable": true,
      "readable": true,
      "comparable": true,
      "discoverable": true
    }
  ]
}

EOF

func (*SchemaFieldAccessUpdateHandler) GetPreprocessors added in v1.1.0

func (h *SchemaFieldAccessUpdateHandler) GetPreprocessors() []router.Processor

func (*SchemaFieldAccessUpdateHandler) Handle added in v1.1.0

func (h *SchemaFieldAccessUpdateHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SchemaFieldAccessUpdateHandler) Setup added in v1.1.0

func (h *SchemaFieldAccessUpdateHandler) Setup()

type SchemaRenameHandler

type SchemaRenameHandler struct {
	EventSender pluginEvent.Sender `inject:"PluginEventSender"`
	AccessKey   router.Processor   `preprocessor:"accesskey"`
	DevOnly     router.Processor   `preprocessor:"dev_only"`
	DBConn      router.Processor   `preprocessor:"dbconn"`
	InjectDB    router.Processor   `preprocessor:"inject_db"`
	PluginReady router.Processor   `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SchemaRenameHandler handles the action of renaming column

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/schema/rename <<EOF
{
	"master_key": "MASTER_KEY",
	"action": "schema:rename",
	"record_type": "student",
	"item_type": "field",
	"item_name": "score",
	"new_name": "exam_score"
}

EOF

func (*SchemaRenameHandler) GetPreprocessors

func (h *SchemaRenameHandler) GetPreprocessors() []router.Processor

func (*SchemaRenameHandler) Handle

func (h *SchemaRenameHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SchemaRenameHandler) Setup

func (h *SchemaRenameHandler) Setup()

type SetDisableUserHandler added in v1.4.0

type SetDisableUserHandler struct {
	TokenStore    authtoken.Store  `inject:"TokenStore"`
	AssetStore    asset.Store      `inject:"AssetStore"`
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"inject_auth"`
	RequireAdmin  router.Processor `preprocessor:"require_admin"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SetDisableUserHandler set disabled flag for the specified user

SetDisableUserHandler receives these parameters:

* auth_id (string, required) * disabled (boolean, required) * message (string, optional) * expiry (date/time, optional)

Current implementation:

```

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "auth:disable:set",
    "auth_id": "77FA8BCF-CD6C-4A22-A170-CECC2667654F"
}

EOF ```

Response: * success response

func (*SetDisableUserHandler) GetPreprocessors added in v1.4.0

func (h *SetDisableUserHandler) GetPreprocessors() []router.Processor

func (*SetDisableUserHandler) Handle added in v1.4.0

func (h *SetDisableUserHandler) Handle(payload *router.Payload, response *router.Response)

func (*SetDisableUserHandler) Setup added in v1.4.0

func (h *SetDisableUserHandler) Setup()

type SignupHandler

type SignupHandler struct {
	TokenStore       authtoken.Store        `inject:"TokenStore"`
	ProviderRegistry *provider.Registry     `inject:"ProviderRegistry"`
	HookRegistry     *hook.Registry         `inject:"HookRegistry"`
	AssetStore       asset.Store            `inject:"AssetStore"`
	AccessModel      skydb.AccessModel      `inject:"AccessModel"`
	AuthRecordKeys   [][]string             `inject:"AuthRecordKeys"`
	PasswordChecker  *audit.PasswordChecker `inject:"PasswordChecker"`
	AccessKey        router.Processor       `preprocessor:"accesskey"`
	DBConn           router.Processor       `preprocessor:"dbconn"`
	InjectPublicDB   router.Processor       `preprocessor:"inject_public_db"`
	PluginReady      router.Processor       `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SignupHandler creates an AuthInfo with the supplied information.

SignupHandler receives three parameters:

* auth_data (json object, optional) * password (string, optional)

If auth_data is not supplied, an anonymous user is created and have user_id auto-generated. SignupHandler writes an error to response.Result if the supplied username or email collides with an existing username.

Any entry with null value in auth_data would be purged. If all entries are having null value, this would be treated as anonymous sign up.

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "auth:signup",
    "auth_data": {
      "username": "rickmak",
      "email": "rick.mak@gmail.com",
    },
    "password": "123456"
}
EOF

func (*SignupHandler) GetPreprocessors

func (h *SignupHandler) GetPreprocessors() []router.Processor

func (*SignupHandler) Handle

func (h *SignupHandler) Handle(payload *router.Payload, response *router.Response)

func (*SignupHandler) Setup

func (h *SignupHandler) Setup()

type SignupProviderHandler added in v1.2.0

type SignupProviderHandler struct {
	TokenStore       authtoken.Store  `inject:"TokenStore"`
	HookRegistry     *hook.Registry   `inject:"HookRegistry"`
	AssetStore       asset.Store      `inject:"AssetStore"`
	AuthRecordKeys   [][]string       `inject:"AuthRecordKeys"`
	AccessKey        router.Processor `preprocessor:"accesskey"`
	DBConn           router.Processor `preprocessor:"dbconn"`
	InjectPublicDB   router.Processor `preprocessor:"inject_public_db"`
	PluginReady      router.Processor `preprocessor:"plugin_ready"`
	RequireMasterKey router.Processor `preprocessor:"require_master_key"`
	// contains filtered or unexported fields
}

func (*SignupProviderHandler) GetPreprocessors added in v1.2.0

func (h *SignupProviderHandler) GetPreprocessors() []router.Processor

func (*SignupProviderHandler) Handle added in v1.2.0

func (h *SignupProviderHandler) Handle(payload *router.Payload, response *router.Response)

func (*SignupProviderHandler) Setup added in v1.2.0

func (h *SignupProviderHandler) Setup()

type SubscriptionDeleteHandler

type SubscriptionDeleteHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"require_auth"`
	InjectDB      router.Processor `preprocessor:"inject_db"`
	CheckUser     router.Processor `preprocessor:"check_user"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SubscriptionDeleteHandler deletes subscriptions from the specified Database.

Example curl:

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "subscription:delete",
    "access_token": "ACCESS_TOKEN",
    "database_id": "_private",
    "subscription_ids": ["SUBSCRIPTION_ID"]
}
EOF

func (*SubscriptionDeleteHandler) GetPreprocessors

func (h *SubscriptionDeleteHandler) GetPreprocessors() []router.Processor

func (*SubscriptionDeleteHandler) Handle

func (h *SubscriptionDeleteHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SubscriptionDeleteHandler) Setup

func (h *SubscriptionDeleteHandler) Setup()

type SubscriptionFetchAllHandler

type SubscriptionFetchAllHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"require_auth"`
	InjectDB      router.Processor `preprocessor:"inject_db"`
	CheckUser     router.Processor `preprocessor:"check_user"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SubscriptionFetchAllHandler fetches all subscriptions of a device

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "subscription:fetch_all",
    "access_token": "ACCESS_TOKEN",
    "database_id": "_private",
    "device_id": "DEVICE_ID"
}
EOF

func (*SubscriptionFetchAllHandler) GetPreprocessors

func (h *SubscriptionFetchAllHandler) GetPreprocessors() []router.Processor

func (*SubscriptionFetchAllHandler) Handle

func (h *SubscriptionFetchAllHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SubscriptionFetchAllHandler) Setup

func (h *SubscriptionFetchAllHandler) Setup()

type SubscriptionFetchHandler

type SubscriptionFetchHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"require_auth"`
	InjectDB      router.Processor `preprocessor:"inject_db"`
	CheckUser     router.Processor `preprocessor:"check_user"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SubscriptionFetchHandler fetches subscriptions from the specified Database.

Example curl:

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "subscription:fetch",
    "access_token": "ACCESS_TOKEN",
    "database_id": "_private",
    "device_id": "DEVICE_ID",
    "subscription_ids": ["SUBSCRIPTION_ID"]
}
EOF

func (*SubscriptionFetchHandler) GetPreprocessors

func (h *SubscriptionFetchHandler) GetPreprocessors() []router.Processor

func (*SubscriptionFetchHandler) Handle

func (h *SubscriptionFetchHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SubscriptionFetchHandler) Setup

func (h *SubscriptionFetchHandler) Setup()

type SubscriptionSaveHandler

type SubscriptionSaveHandler struct {
	Authenticator router.Processor `preprocessor:"authenticator"`
	DBConn        router.Processor `preprocessor:"dbconn"`
	InjectAuth    router.Processor `preprocessor:"require_auth"`
	InjectDB      router.Processor `preprocessor:"inject_db"`
	CheckUser     router.Processor `preprocessor:"check_user"`
	PluginReady   router.Processor `preprocessor:"plugin_ready"`
	// contains filtered or unexported fields
}

SubscriptionSaveHandler saves one or more subscriptions associate with a database.

Example curl:

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
    "action": "subscription:save",
    "access_token": "ACCESS_TOKEN",
    "database_id": "_private",
    "device_id": "DEVICE_ID",
    "subscriptions": [
        {
            "id": "SUBSCRIPTION_ID",
            "notification_info": {
                "aps": {
                    "alert": {
                        "body": "BODY_TEXT",
                        "action-loc-key": "ACTION_LOC_KEY",
                        "loc-key": "LOC_KEY",
                        "loc-args": ["LOC_ARGS"],
                        "launch-image": "LAUNCH_IMAGE"
                    },
                    "sound": "SOUND_NAME",
                    "should-badge": true,
                    "should-send-content-available": true
                }
            },
            "type": "query",
            "query": {
                "record_type": "RECORD_TYPE",
                "predicate": {}
            }
        }
    ]
}
EOF

func (*SubscriptionSaveHandler) GetPreprocessors

func (h *SubscriptionSaveHandler) GetPreprocessors() []router.Processor

func (*SubscriptionSaveHandler) Handle

func (h *SubscriptionSaveHandler) Handle(rpayload *router.Payload, response *router.Response)

func (*SubscriptionSaveHandler) Setup

func (h *SubscriptionSaveHandler) Setup()

type UnlinkProviderHandler added in v1.2.0

type UnlinkProviderHandler struct {
	HookRegistry     *hook.Registry   `inject:"HookRegistry"`
	AssetStore       asset.Store      `inject:"AssetStore"`
	AuthRecordKeys   [][]string       `inject:"AuthRecordKeys"`
	AccessKey        router.Processor `preprocessor:"accesskey"`
	DBConn           router.Processor `preprocessor:"dbconn"`
	InjectPublicDB   router.Processor `preprocessor:"inject_public_db"`
	PluginReady      router.Processor `preprocessor:"plugin_ready"`
	RequireMasterKey router.Processor `preprocessor:"require_master_key"`
	// contains filtered or unexported fields
}

UnlinkProviderHandler disconnect user with specific provider

UnlinkProviderHandler receives parameters:

* provider (string, required) * user_id (string, required)

curl -X POST -H "Content-Type: application/json" \
  -d @- http://localhost:3000/ <<EOF
{
		"action": "sso:oauth:unlink",
		"provider": "facebook",
		"user_id": "c0959b6b-15ea-4e21-8afb-9c8308ad79db"
}

EOF Response

{
    "result": "OK"
}

func (*UnlinkProviderHandler) GetPreprocessors added in v1.2.0

func (h *UnlinkProviderHandler) GetPreprocessors() []router.Processor

func (*UnlinkProviderHandler) Handle added in v1.2.0

func (h *UnlinkProviderHandler) Handle(payload *router.Payload, response *router.Response)

func (*UnlinkProviderHandler) Setup added in v1.2.0

func (h *UnlinkProviderHandler) Setup()

type UploadFileHandler

type UploadFileHandler struct {
	AssetStore skyAsset.Store   `inject:"AssetStore"`
	AccessKey  router.Processor `preprocessor:"accesskey"`
	DBConn     router.Processor `preprocessor:"dbconn"`
	// contains filtered or unexported fields
}

UploadFileHandler receives and persists a file to be associated by Record.

Example curl (PUT):

curl -XPUT \
	-H 'X-Skygear-API-Key: apiKey' \
	-H 'Content-Type: text/plain' \
	--data-binary '@file.txt' \
	http://localhost:3000/files/filename

Example curl (POST):

	curl -XPOST \
   -H "X-Skygear-API-Key: apiKey" \
   -F 'file=@file.txt' \
   http://localhost:3000/files/filename

func (*UploadFileHandler) GetPreprocessors

func (h *UploadFileHandler) GetPreprocessors() []router.Processor

GetPreprocessors returns all preprocessors

func (*UploadFileHandler) Handle

func (h *UploadFileHandler) Handle(
	payload *router.Payload,
	response *router.Response,
)

Handle handles the upload asset request

func (*UploadFileHandler) Setup

func (h *UploadFileHandler) Setup()

Setup sets preprocessors being used

type UserAuthFetcher added in v1.1.0

type UserAuthFetcher struct {
	DBConn   skydb.Conn
	Database skydb.Database
}

UserAuthFetcher provides helper functions to fetch AuthInfo and user Record with AuthData in a single structs

func (*UserAuthFetcher) FetchAuth added in v1.1.0

func (f *UserAuthFetcher) FetchAuth(authData skydb.AuthData) (authInfo skydb.AuthInfo, user skydb.Record, err error)

func (*UserAuthFetcher) FetchUser added in v1.1.0

func (f *UserAuthFetcher) FetchUser(authData skydb.AuthData) (user skydb.Record, err error)

FetchUser fetches user record by AuthData for auth, e.g. login The query should not be affected by the user record acl so this function bypasses access control

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL