Skip to content

ITP-2120 add oauth#2

Open
gnomeby wants to merge 3 commits intomasterfrom
feature/ITP-2102_add_oauth
Open

ITP-2120 add oauth#2
gnomeby wants to merge 3 commits intomasterfrom
feature/ITP-2102_add_oauth

Conversation

@gnomeby
Copy link
Collaborator

@gnomeby gnomeby commented Nov 14, 2025

@gnomeby
Copy link
Collaborator Author

gnomeby commented Nov 14, 2025

Надо завернуть приложение в middleware, пример тут:
https://gitlab.vizor-games.com/internal-tools-python/keycloak-auth-proxy/-/blob/main/src/example_proxy_app.py?ref_type=heads

Copy link
Collaborator Author

@gnomeby gnomeby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужен механиз Logout

os.environ.get('OIDC_SERVER_METADATA_URL')]) and WITH_OAUTH:
app.register_blueprint(oauth_bp, url_prefix='/auth')
oauth.init_app(app)
add_oauth()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add_oauth_auth


# If env variables for oauth and required packages are present add optional oauth protection
if all([os.environ.get('OIDC_CLIENT_ID'), os.environ.get('OIDC_CLIENT_SECRET'),
os.environ.get('OIDC_SERVER_METADATA_URL')]) and WITH_OAUTH:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если WITH_OAUTH == False и при этом заданы OIDC параметры, то надо ругаться


oauth.register(
name='oidc_provider',
client_id=OIDC_CLIENT_ID,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разобраться должно ли быть OAUTH2_ или OPENID_

client_secret=OIDC_CLIENT_SECRET,
server_metadata_url=OIDC_SERVER_METADATA_URL,
client_kwargs={
'scope': 'openid email profile'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выяснить минимальный набор

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Должно быть настраиваемо



@oauth_bp.route('/')
def index():
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется ненужно

app.config.from_envvar("RQ_DASHBOARD_SETTINGS")

# If env variables for oauth and required packages are present add optional oauth protection
if all([os.environ.get('OIDC_CLIENT_ID'), os.environ.get('OIDC_CLIENT_SECRET'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Передача параметров должна соответствовать шалону приложения: можно через env, можно через.cfg, можно через командную строку

def auth_callback():
try:
token = oauth.oidc_provider.authorize_access_token()
session['user'] = token.get('userinfo')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

После разбора со scope выяснить какое уникальное значение всегда будет.

extras_require={
'oauth': [
'Authlib>=1.6.5',
'python-dotenv>=1.2.1',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эта библиотека не должна быть обязательной

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

она записана в extras, и будет устанавливаться дополнительно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants