-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement OAuth 2.0 Authorization Server Metadata - closes #3143
- Loading branch information
1 parent
3ef05a7
commit 9cab2bf
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Well-Known Controller | ||
* | ||
* Handles HTTP requests to /.well-known | ||
*/ | ||
|
||
import express from 'express'; | ||
import * as Constants from '../constants'; | ||
|
||
function build(): express.Router { | ||
const controller = express.Router(); | ||
|
||
/** | ||
* OAuth 2.0 Authorization Server Metadata (RFC 8414) | ||
*/ | ||
controller.get('/oauth-authorization-server', (request, response) => { | ||
const origin = `${request.protocol}://${request.headers.host}`; | ||
response.json({ | ||
issuer: origin, | ||
authorization_endpoint: `${origin}${Constants.OAUTH_PATH}/authorize`, | ||
token_endpoint: `${origin}${Constants.OAUTH_PATH}/token`, | ||
response_types_supported: ['code'], | ||
// Only expose top-level scopes to unauthenticated clients | ||
scopes_supported: [Constants.THINGS_PATH, `${Constants.THINGS_PATH}:readwrite`], | ||
}); | ||
}); | ||
|
||
return controller; | ||
} | ||
|
||
export default build; |
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