Documentation
¶
Index ¶
- Constants
- func ContextWithPolicy(ctx context.Context, p *GQLPolicy) context.Context
- func NewGraphQLClaims(id uuid.UUID, policyHash []byte, expires time.Time) jwt.Claims
- type APIKeyInfo
- type APIKeyUsage
- type Claims
- type GQLPolicy
- type Middleware
- type NewAdminGQLKeyOpts
- type Store
- func (s *Store) AuthorizeGraphQL(ctx context.Context, tok, ua, ip string) (context.Context, error)
- func (s *Store) CreateAdminGraphQLKey(ctx context.Context, opt NewAdminGQLKeyOpts) (uuid.UUID, string, error)
- func (s *Store) DeleteAdminGraphQLKey(ctx context.Context, id uuid.UUID) error
- func (s *Store) FindAllAdminGraphQLKeys(ctx context.Context) ([]APIKeyInfo, error)
- func (s *Store) UpdateAdminGraphQLKey(ctx context.Context, id uuid.UUID, name, desc *string) error
- type UpdateKey
Constants ¶
const Audience = "apikey-v1/graphql-v1"
Audience is the JWT audience for GraphQL API keys.
const Issuer = "goalert"
Issuer is the JWT issuer for GraphQL API keys.
Variables ¶
This section is empty.
Functions ¶
func ContextWithPolicy ¶
ContextWithPolicy returns a new context with the given Policy attached.
Types ¶
type APIKeyInfo ¶
type Claims ¶
type Claims struct { jwt.RegisteredClaims PolicyHash []byte `json:"pol"` }
Claims is the set of claims that are encoded into a JWT for a GraphQL API key.
type GQLPolicy ¶
type GQLPolicy struct { Version int Query string Role permission.Role }
GQLPolicy is a GraphQL API key policy.
Any changes to existing fields MUST require the version to be incremented.
If new fields are added, they MUST be set to `omitempty` to ensure existing keys don't break.
It MUST be possible to unmarshal & re-marshal the policy without changing the data for existing keys.
func PolicyFromContext ¶
PolicyFromContext returns the Policy associated with the given context.
type Middleware ¶
type Middleware struct{}
func (Middleware) ExtensionName ¶
func (Middleware) ExtensionName() string
func (Middleware) MutateOperationParameters ¶
func (Middleware) Validate ¶
func (Middleware) Validate(schema graphql.ExecutableSchema) error
type NewAdminGQLKeyOpts ¶
type NewAdminGQLKeyOpts struct { Name string Desc string Expires time.Time Role permission.Role Query string }
NewAdminGQLKeyOpts is used to create a new GraphQL API key.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is used to manage API keys.
func (*Store) AuthorizeGraphQL ¶
func (*Store) CreateAdminGraphQLKey ¶
func (s *Store) CreateAdminGraphQLKey(ctx context.Context, opt NewAdminGQLKeyOpts) (uuid.UUID, string, error)
CreateAdminGraphQLKey will create a new GraphQL API key returning the ID and token.
func (*Store) DeleteAdminGraphQLKey ¶
func (*Store) FindAllAdminGraphQLKeys ¶
func (s *Store) FindAllAdminGraphQLKeys(ctx context.Context) ([]APIKeyInfo, error)