forked from swagger-api/swagger-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve: OAuth2 UI and test suite (via swagger-api#5066)
* create `features` folder * add base oauth2 server * continue implementing OAuth tests * WIP * add password flow tests * modify Password flow credential types * remove query string credential type * add test case for Authorization flow * add specific Authorization value for Password flow test * WIP * fix linter issues
- Loading branch information
Showing
14 changed files
with
504 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// from https://github.com/pedroetb/node-oauth2-server-example | ||
|
||
var Http = require("http") | ||
var path = require("path") | ||
var express = require("express") | ||
var bodyParser = require("body-parser") | ||
var oauthserver = require("oauth2-server") | ||
var cors = require("cors") | ||
|
||
var app = express() | ||
|
||
app.use(cors()) | ||
|
||
app.use(bodyParser.urlencoded({ extended: true })) | ||
|
||
app.use(bodyParser.json()) | ||
|
||
app.oauth = oauthserver({ | ||
model: require("./model.js"), | ||
grants: ["password", "client_credentials", "implicit"], | ||
debug: true | ||
}) | ||
|
||
app.all("/oauth/token", app.oauth.grant()) | ||
|
||
app.get("/swagger.yaml", function (req, res) { | ||
res.sendFile(path.join(__dirname, "swagger.yaml")) | ||
}) | ||
|
||
app.get("*", app.oauth.authorise(), function (req, res) { | ||
res.send("Secret secrets are no fun, secret secrets hurt someone.") | ||
}) | ||
|
||
app.use(app.oauth.errorHandler()) | ||
|
||
function startServer() { | ||
var httpServer = Http.createServer(app) | ||
httpServer.listen("3231") | ||
|
||
return function stopServer() { | ||
httpServer.close() | ||
} | ||
} | ||
|
||
module.exports = startServer | ||
|
||
if (require.main === module) { | ||
// for debugging | ||
startServer() | ||
} |
Oops, something went wrong.