Skip to content

Commit

Permalink
regen examples
Browse files Browse the repository at this point in the history
Fix #1496
  • Loading branch information
fredbi committed Jul 4, 2018
1 parent df3d7a3 commit 96ed827
Show file tree
Hide file tree
Showing 142 changed files with 1,927 additions and 1,547 deletions.
6 changes: 3 additions & 3 deletions docs/tutorial/oauth2/README.md
Expand Up @@ -97,8 +97,8 @@ var (
state = "foobar" // Don't make this a global in production.

// the credentials for this API (adapt values when registering API)
clientID = ""
clientSecret = ""
clientID = "" // <= enter registered API client ID here
clientSecret = "" // <= enter registered API client secret here

// unused in this example: the signer of the delivered token
issuer = "https://accounts.google.com"
Expand Down Expand Up @@ -213,7 +213,7 @@ We set the following implementation for authentication in `restapi/implementatio
func login(r *http.Request) string {
// implements the login with a redirection and an access token
var accessToken string
http.Redirect(wG, r, config.AuthCodeURL(state), http.StatusFound)
wG := r.Context().Value(ctxResponseWriter).(http.ResponseWriter)
log.Println("Access token:", accessToken)
return accessToken
}
Expand Down
4 changes: 2 additions & 2 deletions examples/2.0/petstore/server/api/petstore.go
Expand Up @@ -93,8 +93,8 @@ type Pet struct {
}

var pets = []Pet{
{1, "Dog", []string{}, "available", nil},
{2, "Cat", []string{}, "pending", nil},
{ID: 1, Name: "Dog", PhotoURLs: []string{}, Status: "available", Tags: nil},
{ID: 2, Name: "Cat", PhotoURLs: []string{}, Status: "pending", Tags: nil},
}

var petsLock = &sync.Mutex{}
Expand Down
2 changes: 1 addition & 1 deletion examples/2.0/petstore/server/petstore.go
Expand Up @@ -27,5 +27,5 @@ func main() {
log.Fatalln(err)
}
log.Println("Serving petstore api on http://127.0.0.1:8344/swagger-ui/")
http.ListenAndServe(":8344", petstoreAPI)
_ = http.ListenAndServe(":8344", petstoreAPI)
}
3 changes: 1 addition & 2 deletions examples/authentication/cmd/auth-sample-server/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions examples/authentication/models/customer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/authentication/models/error.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/authentication/models/social_id.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions examples/authentication/restapi/configure_auth_sample.go
Expand Up @@ -9,7 +9,6 @@ import (
errors "github.com/go-openapi/errors"
runtime "github.com/go-openapi/runtime"
middleware "github.com/go-openapi/runtime/middleware"
graceful "github.com/tylerb/graceful"

"github.com/go-swagger/go-swagger/examples/authentication/restapi/operations"
"github.com/go-swagger/go-swagger/examples/authentication/restapi/operations/customers"
Expand Down Expand Up @@ -47,7 +46,6 @@ func configureAPI(api *operations.AuthSampleAPI) http.Handler {
//
// Example:
// api.APIAuthorizer = security.Authorized()

api.CustomersCreateHandler = customers.CreateHandlerFunc(func(params customers.CreateParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation customers.Create has not yet been implemented")
})
Expand All @@ -69,7 +67,7 @@ func configureTLS(tlsConfig *tls.Config) {
// If you need to modify a config, store server instance to stop it individually later, this is the place.
// This function can be called multiple times, depending on the number of serving schemes.
// scheme value will be set accordingly: "http", "https" or "unix"
func configureServer(s *graceful.Server, scheme, addr string) {
func configureServer(s *http.Server, scheme, addr string) {
}

// The middleware configuration is for the handler executors. These do not apply to the swagger.json document.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 79 additions & 27 deletions examples/authentication/restapi/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions examples/composed-auth/auth/authorizers.go
Expand Up @@ -10,16 +10,17 @@ import (
)

const (
privateKeyPath = "keys/apiKey.prv"
publicKeyPath = "keys/apiKey.pem"
// currently unused: privateKeyPath = "keys/apiKey.prv"
publicKeyPath = "keys/apiKey.pem"
issuerName = "example.com"
)

var (
userDb map[string]string

// Keys used to sign and verify our tokens
verifyKey *rsa.PublicKey
signKey *rsa.PrivateKey
// currently unused: signKey *rsa.PrivateKey
)

// roleClaims describes the format of our JWT token's claims
Expand Down Expand Up @@ -65,7 +66,7 @@ func IsRegistered(user, pass string) (*models.Principal, error) {
func IsReseller(token string) (*models.Principal, error) {
claims, err := parseAndCheckToken(token)
if err == nil {
if claims.Issuer == "example.com" && claims.Id != "" {
if claims.Issuer == issuerName && claims.Id != "" {
isReseller := false
for _, role := range claims.Roles {
if role == "reseller" {
Expand All @@ -90,7 +91,7 @@ func IsReseller(token string) (*models.Principal, error) {
func HasRole(token string, scopes []string) (*models.Principal, error) {
claims, err := parseAndCheckToken(token)
if err == nil {
if claims.Issuer == "example.com" {
if claims.Issuer == issuerName {
isInScopes := false
claimedRoles := []string{}
for _, scope := range scopes {
Expand Down
3 changes: 1 addition & 2 deletions examples/composed-auth/cmd/multi-auth-example-server/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/composed-auth/models/error.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 96ed827

Please sign in to comment.