func NewAPIServer(config *APIConfig, role teleport.Role) APIServer {
	srv := APIServer{
		a: AuthWithRoles{
			authServer:  config.AuthServer,
			permChecker: config.PermissionChecker,
			sessions:    config.SessionService,
			alog:        config.AuditLog,
			role:        role,
		},
	}
	srv.Router = *httprouter.New()

	// Operations on certificate authorities
	srv.GET("/v1/domain", httplib.MakeHandler(srv.getDomainName))
	srv.POST("/v1/authorities/:type", httplib.MakeHandler(srv.upsertCertAuthority))
	srv.DELETE("/v1/authorities/:type/:domain", httplib.MakeHandler(srv.deleteCertAuthority))
	srv.GET("/v1/authorities/:type", httplib.MakeHandler(srv.getCertAuthorities))

	// Generating certificates for user and host authorities
	srv.POST("/v1/ca/host/certs", httplib.MakeHandler(srv.generateHostCert))
	srv.POST("/v1/ca/user/certs", httplib.MakeHandler(srv.generateUserCert))

	// Operations on users
	srv.GET("/v1/users", httplib.MakeHandler(srv.getUsers))
	srv.GET("/v1/users/:user", httplib.MakeHandler(srv.getUser))
	srv.DELETE("/v1/users/:user", httplib.MakeHandler(srv.deleteUser))

	// Generating keypairs
	srv.POST("/v1/keypair", httplib.MakeHandler(srv.generateKeyPair))

	// Passwords and sessions
	srv.POST("/v1/users", httplib.MakeHandler(srv.upsertUser))
	srv.POST("/v1/users/:user/web/password", httplib.MakeHandler(srv.upsertPassword))
	srv.POST("/v1/users/:user/web/password/check", httplib.MakeHandler(srv.checkPassword))
	srv.POST("/v1/users/:user/web/signin", httplib.MakeHandler(srv.signIn))
	srv.POST("/v1/users/:user/web/sessions", httplib.MakeHandler(srv.createWebSession))
	srv.GET("/v1/users/:user/web/sessions/:sid", httplib.MakeHandler(srv.getWebSession))
	srv.DELETE("/v1/users/:user/web/sessions/:sid", httplib.MakeHandler(srv.deleteWebSession))
	srv.GET("/v1/signuptokens/:token", httplib.MakeHandler(srv.getSignupTokenData))
	srv.POST("/v1/signuptokens/users", httplib.MakeHandler(srv.createUserWithToken))
	srv.POST("/v1/signuptokens", httplib.MakeHandler(srv.createSignupToken))

	// Servers and presence heartbeat
	srv.POST("/v1/nodes", httplib.MakeHandler(srv.upsertNode))
	srv.GET("/v1/nodes", httplib.MakeHandler(srv.getNodes))
	srv.POST("/v1/authservers", httplib.MakeHandler(srv.upsertAuthServer))
	srv.GET("/v1/authservers", httplib.MakeHandler(srv.getAuthServers))
	srv.POST("/v1/proxies", httplib.MakeHandler(srv.upsertProxy))
	srv.GET("/v1/proxies", httplib.MakeHandler(srv.getProxies))

	// Reverse tunnels
	srv.POST("/v1/reversetunnels", httplib.MakeHandler(srv.upsertReverseTunnel))
	srv.GET("/v1/reversetunnels", httplib.MakeHandler(srv.getReverseTunnels))
	srv.DELETE("/v1/reversetunnels/:domain", httplib.MakeHandler(srv.deleteReverseTunnel))

	// Tokens
	srv.POST("/v1/tokens", httplib.MakeHandler(srv.generateToken))
	srv.POST("/v1/tokens/register", httplib.MakeHandler(srv.registerUsingToken))
	srv.POST("/v1/tokens/register/auth", httplib.MakeHandler(srv.registerNewAuthServer))

	// Sesssions
	srv.POST("/v1/sessions", httplib.MakeHandler(srv.createSession))
	srv.PUT("/v1/sessions/:id", httplib.MakeHandler(srv.updateSession))
	srv.GET("/v1/sessions", httplib.MakeHandler(srv.getSessions))
	srv.GET("/v1/sessions/:id", httplib.MakeHandler(srv.getSession))
	srv.POST("/v1/sessions/:id/stream", httplib.MakeHandler(srv.postSessionChunk))
	srv.GET("/v1/sessions/:id/stream", srv.getSessionChunk)
	srv.GET("/v1/sessions/:id/events", httplib.MakeHandler(srv.getSessionEvents))

	// OIDC stuff
	srv.POST("/v1/oidc/connectors", httplib.MakeHandler(srv.upsertOIDCConnector))
	srv.GET("/v1/oidc/connectors", httplib.MakeHandler(srv.getOIDCConnectors))
	srv.GET("/v1/oidc/connectors/:id", httplib.MakeHandler(srv.getOIDCConnector))
	srv.DELETE("/v1/oidc/connectors/:id", httplib.MakeHandler(srv.deleteOIDCConnector))
	srv.POST("/v1/oidc/requests/create", httplib.MakeHandler(srv.createOIDCAuthRequest))
	srv.POST("/v1/oidc/requests/validate", httplib.MakeHandler(srv.validateOIDCAuthCallback))

	// Provisioning tokens
	srv.GET("/v1/tokens", httplib.MakeHandler(srv.getTokens))
	srv.DELETE("/v1/tokens/:token", httplib.MakeHandler(srv.deleteToken))

	// Audit logs AKA events
	srv.POST("/v1/events", httplib.MakeHandler(srv.emitAuditEvent))
	srv.GET("/v1/events", httplib.MakeHandler(srv.searchEvents))

	return srv
}
// NewAPIServer returns a new instance of APIServer HTTP handler
NewAPIServer returns a new instance of APIServer HTTP handler
// NewAPIServer returns a new instance of APIServer HTTP handler
func NewAPIServer(config *APIConfig, role teleport.Role) APIServer {
	srv := APIServer{
		a: AuthWithRoles{
			authServer:  config.AuthServer,
			permChecker: config.PermissionChecker,
			sessions:    config.SessionService,
			alog:        config.AuditLog,
			role:        role,
		},
	}
	srv.Router = *httprouter.New()
	srv.GET("/v1/domain", httplib.MakeHandler(srv.getDomainName))
	srv.POST("/v1/authorities/:type", httplib.MakeHandler(srv.upsertCertAuthority))
	srv.DELETE("/v1/authorities/:type/:domain", httplib.MakeHandler(srv.deleteCertAuthority))
	srv.GET("/v1/authorities/:type", httplib.MakeHandler(srv.getCertAuthorities))
	srv.POST("/v1/ca/host/certs", httplib.MakeHandler(srv.generateHostCert))
	srv.POST("/v1/ca/user/certs", httplib.MakeHandler(srv.generateUserCert))
	srv.GET("/v1/users", httplib.MakeHandler(srv.getUsers))
	srv.GET("/v1/users/:user", httplib.MakeHandler(srv.getUser))
	srv.DELETE("/v1/users/:user", httplib.MakeHandler(srv.deleteUser))
	srv.POST("/v1/keypair", httplib.MakeHandler(srv.generateKeyPair))
	srv.POST("/v1/users", httplib.MakeHandler(srv.upsertUser))
	srv.POST("/v1/users/:user/web/password", httplib.MakeHandler(srv.upsertPassword))
	srv.POST("/v1/users/:user/web/password/check", httplib.MakeHandler(srv.checkPassword))
	srv.POST("/v1/users/:user/web/signin", httplib.MakeHandler(srv.signIn))
	srv.POST("/v1/users/:user/web/sessions", httplib.MakeHandler(srv.createWebSession))
	srv.GET("/v1/users/:user/web/sessions/:sid", httplib.MakeHandler(srv.getWebSession))
	srv.DELETE("/v1/users/:user/web/sessions/:sid", httplib.MakeHandler(srv.deleteWebSession))
	srv.GET("/v1/signuptokens/:token", httplib.MakeHandler(srv.getSignupTokenData))
	srv.POST("/v1/signuptokens/users", httplib.MakeHandler(srv.createUserWithToken))
	srv.POST("/v1/signuptokens", httplib.MakeHandler(srv.createSignupToken))
	srv.POST("/v1/nodes", httplib.MakeHandler(srv.upsertNode))
	srv.GET("/v1/nodes", httplib.MakeHandler(srv.getNodes))
	srv.POST("/v1/authservers", httplib.MakeHandler(srv.upsertAuthServer))
	srv.GET("/v1/authservers", httplib.MakeHandler(srv.getAuthServers))
	srv.POST("/v1/proxies", httplib.MakeHandler(srv.upsertProxy))
	srv.GET("/v1/proxies", httplib.MakeHandler(srv.getProxies))
	srv.POST("/v1/reversetunnels", httplib.MakeHandler(srv.upsertReverseTunnel))
	srv.GET("/v1/reversetunnels", httplib.MakeHandler(srv.getReverseTunnels))
	srv.DELETE("/v1/reversetunnels/:domain", httplib.MakeHandler(srv.deleteReverseTunnel))
	srv.POST("/v1/tokens", httplib.MakeHandler(srv.generateToken))
	srv.POST("/v1/tokens/register", httplib.MakeHandler(srv.registerUsingToken))
	srv.POST("/v1/tokens/register/auth", httplib.MakeHandler(srv.registerNewAuthServer))
	srv.POST("/v1/sessions", httplib.MakeHandler(srv.createSession))
	srv.PUT("/v1/sessions/:id", httplib.MakeHandler(srv.updateSession))
	srv.GET("/v1/sessions", httplib.MakeHandler(srv.getSessions))
	srv.GET("/v1/sessions/:id", httplib.MakeHandler(srv.getSession))
	srv.POST("/v1/sessions/:id/stream", httplib.MakeHandler(srv.postSessionChunk))
	srv.GET("/v1/sessions/:id/stream", srv.getSessionChunk)
	srv.GET("/v1/sessions/:id/events", httplib.MakeHandler(srv.getSessionEvents))
	srv.POST("/v1/oidc/connectors", httplib.MakeHandler(srv.upsertOIDCConnector))
	srv.GET("/v1/oidc/connectors", httplib.MakeHandler(srv.getOIDCConnectors))
	srv.GET("/v1/oidc/connectors/:id", httplib.MakeHandler(srv.getOIDCConnector))
	srv.DELETE("/v1/oidc/connectors/:id", httplib.MakeHandler(srv.deleteOIDCConnector))
	srv.POST("/v1/oidc/requests/create", httplib.MakeHandler(srv.createOIDCAuthRequest))
	srv.POST("/v1/oidc/requests/validate", httplib.MakeHandler(srv.validateOIDCAuthCallback))
	srv.GET("/v1/tokens", httplib.MakeHandler(srv.getTokens))
	srv.DELETE("/v1/tokens/:token", httplib.MakeHandler(srv.deleteToken))
	srv.POST("/v1/events", httplib.MakeHandler(srv.emitAuditEvent))
	srv.GET("/v1/events", httplib.MakeHandler(srv.searchEvents))
	return srv
}
func NewAPIServer ( config * APIConfig , role teleport . Role ) APIServer { srv := APIServer { a : AuthWithRoles { authServer : config . AuthServer , permChecker : config . PermissionChecker , sessions : config . SessionService , alog : config . AuditLog , role : role , } , } srv . Router = * httprouter . New ( ) srv . GET ( " " , httplib . MakeHandler ( srv . getDomainName ) ) srv . POST ( " " , httplib . MakeHandler ( srv . upsertCertAuthority ) ) srv . DELETE ( " " , httplib . MakeHandler ( srv . deleteCertAuthority ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getCertAuthorities ) ) srv . POST ( " " , httplib . MakeHandler ( srv . generateHostCert ) ) srv . POST ( " " , httplib . MakeHandler ( srv . generateUserCert ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getUsers ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getUser ) ) srv . DELETE ( " " , httplib . MakeHandler ( srv . deleteUser ) ) srv . POST ( " " , httplib . MakeHandler ( srv . generateKeyPair ) ) srv . POST ( " " , httplib . MakeHandler ( srv . upsertUser ) ) srv . POST ( " " , httplib . MakeHandler ( srv . upsertPassword ) ) srv . POST ( " " , httplib . MakeHandler ( srv . checkPassword ) ) srv . POST ( " " , httplib . MakeHandler ( srv . signIn ) ) srv . POST ( " " , httplib . MakeHandler ( srv . createWebSession ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getWebSession ) ) srv . DELETE ( " " , httplib . MakeHandler ( srv . deleteWebSession ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getSignupTokenData ) ) srv . POST ( " " , httplib . MakeHandler ( srv . createUserWithToken ) ) srv . POST ( " " , httplib . MakeHandler ( srv . createSignupToken ) ) srv . POST ( " " , httplib . MakeHandler ( srv . upsertNode ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getNodes ) ) srv . POST ( " " , httplib . MakeHandler ( srv . upsertAuthServer ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getAuthServers ) ) srv . POST ( " " , httplib . MakeHandler ( srv . upsertProxy ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getProxies ) ) srv . POST ( " " , httplib . MakeHandler ( srv . upsertReverseTunnel ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getReverseTunnels ) ) srv . DELETE ( " " , httplib . MakeHandler ( srv . deleteReverseTunnel ) ) srv . POST ( " " , httplib . MakeHandler ( srv . generateToken ) ) srv . POST ( " " , httplib . MakeHandler ( srv . registerUsingToken ) ) srv . POST ( " " , httplib . MakeHandler ( srv . registerNewAuthServer ) ) srv . POST ( " " , httplib . MakeHandler ( srv . createSession ) ) srv . PUT ( " " , httplib . MakeHandler ( srv . updateSession ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getSessions ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getSession ) ) srv . POST ( " " , httplib . MakeHandler ( srv . postSessionChunk ) ) srv . GET ( " " , srv . getSessionChunk ) srv . GET ( " " , httplib . MakeHandler ( srv . getSessionEvents ) ) srv . POST ( " " , httplib . MakeHandler ( srv . upsertOIDCConnector ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getOIDCConnectors ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getOIDCConnector ) ) srv . DELETE ( " " , httplib . MakeHandler ( srv . deleteOIDCConnector ) ) srv . POST ( " " , httplib . MakeHandler ( srv . createOIDCAuthRequest ) ) srv . POST ( " " , httplib . MakeHandler ( srv . validateOIDCAuthCallback ) ) srv . GET ( " " , httplib . MakeHandler ( srv . getTokens ) ) srv . DELETE ( " " , httplib . MakeHandler ( srv . deleteToken ) ) srv . POST ( " " , httplib . MakeHandler ( srv . emitAuditEvent ) ) srv . GET ( " " , httplib . MakeHandler ( srv . searchEvents ) ) return srv }
NewAPIServer returns a new instance of APIServer HTTP handler
NewAPIServer returns a new instance of APIServer HTTP handler
// Operations on certificate authorities // Generating certificates for user and host authorities // Operations on users // Generating keypairs // Passwords and sessions // Servers and presence heartbeat // Reverse tunnels // Tokens // Sesssions // OIDC stuff // Provisioning tokens // Audit logs AKA events