Skip to content
This repository was archived by the owner on Oct 3, 2020. It is now read-only.

Commit e265ca4

Browse files
jarik2995hjacobs
authored andcommitted
Add support for OAuth2 scope parameter (#199)
* Add support for OAuth2 scope parameter * Add description for OAuth2 scope parameter * Update docs with OAuth2 scope parameter * Make request params None if no scope
1 parent 34bb4d6 commit e265ca4

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ The following environment variables are supported:
131131
Optional OAuth 2 authorization endpoint URL for protecting the UI.
132132
``ACCESS_TOKEN_URL``
133133
Optional token endpoint URL for the OAuth 2 Authorization Code Grant flow.
134+
``SCOPE``
135+
Optional scope specifies level of access that the application is requesting.
134136
``CLUSTERS``
135137
Comma separated list of Kubernetes API server URLs. It defaults to ``http://localhost:8001/`` (default endpoint of ``kubectl proxy``).
136138
``CLUSTER_REGISTRY_URL``

docs/access-control.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Relevant configuration settings (environment variables) for OAuth are:
1212
OAuth 2 authorization endpoint URL, e.g. https://oauth2.example.org/authorize
1313
``ACCESS_TOKEN_URL``
1414
Token endpoint URL for the OAuth 2 Authorization Code Grant flow, e.g. https://oauth2.example.org/token
15+
``SCOPE``
16+
OAuth 2 scopes provide a way to limit the amount of access that is granted to an access token, e.g. https://oauth2.example.org/authorize/readonly
1517
``CREDENTIALS_DIR``
1618
Folder path to load client credentials from. The folder needs to contain two files: ``authcode-client-id`` and ``authcode-client-secret``.
1719

kube_ops_view/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
SERVER_STATUS = {'shutdown': False}
3535
AUTHORIZE_URL = os.getenv('AUTHORIZE_URL')
3636
APP_URL = os.getenv('APP_URL')
37+
SCOPE = os.getenv('SCOPE')
3738

3839
app = Flask(__name__)
3940

@@ -45,7 +46,8 @@
4546
request_token_url=None,
4647
access_token_method='POST',
4748
access_token_url=os.getenv('ACCESS_TOKEN_URL'),
48-
authorize_url=AUTHORIZE_URL
49+
authorize_url=AUTHORIZE_URL,
50+
request_token_params={'scope': SCOPE} if SCOPE else None
4951
)
5052
oauth.remote_apps['auth'] = auth
5153

0 commit comments

Comments
 (0)