rest

package
v1.0.0-alpha.27 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package rest provides an http oauth REST API

Index

Constants

View Source
const (
	// AuthRequestParam is the name of the request token parameter
	AuthRequestParam = "request_token"

	// SessionCookie is the name the session cookie
	SessionCookie = "_atomic_session"
)
View Source
const (
	// Name the server name
	Name = "libatomic-oauth"

	// Version is the binary version
	Version = "1.0.0"
)

Variables

View Source
var (
	// SwaggerJSON embedded version of the swagger document used at generation time
	SwaggerJSON json.RawMessage
	// FlatSwaggerJSON embedded flattened version of the swagger document used at generation time
	FlatSwaggerJSON json.RawMessage

	SpecDoc *loads.Document
)

Functions

This section is empty.

Types

type Option

type Option func(*Server)

Option provides the server options, these will override th defaults and instance values.

func WithAddr

func WithAddr(addr string) Option

WithAddr sets the listen address for the server

func WithAllowPasswordGrant

func WithAllowPasswordGrant(allow bool) Option

WithAllowPasswordGrant enables password grants which require client secrets

func WithAllowSignup

func WithAllowSignup(allow bool) Option

WithAllowSignup enables the signup/register paths

func WithBasepath

func WithBasepath(basePath string) Option

WithBasepath sets the server basepath

func WithCodeStore

func WithCodeStore(store oauth.CodeStore) Option

WithCodeStore sets the code store for the server

func WithLogger

func WithLogger(logger *logrus.Logger) Option

WithLogger specifies a new logger

func WithRouter

func WithRouter(router *mux.Router) Option

WithRouter specifies the router to use

func WithSessionCookieName

func WithSessionCookieName(name string) Option

WithSessionCookieName sets the session cookie name

func WithSessionIntervals

func WithSessionIntervals(lifetime, timeout time.Duration) Option

WithSessionIntervals sets the session lifetime and activity timeout

func WithSessionStore

func WithSessionStore(store sessions.Store) Option

WithSessionStore sets the session store

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an API server it can be used standalone vi Server() or integrared via Handler()

func New

func New(ctrl oauth.Controller, signingKey *rsa.PrivateKey, opts ...Option) *Server

New returns a new Server instance

func (*Server) AuthorizeRequest

func (s *Server) AuthorizeRequest(r *http.Request, scope ...oauth.Permissions) (oauth.Context, error)

AuthorizeRequest implements the auth.Authorizer interface

func (*Server) Router

func (s *Server) Router() *mux.Router

Router returns the server router

func (*Server) Serve

func (s *Server) Serve() error

Serve starts the http server

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown shuts down the http server with the context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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