|
46 | 46 | logger = logging.getLogger(__name__) |
47 | 47 |
|
48 | 48 |
|
| 49 | +class MirrorPublicSubjectIdentifierFactory(HashBasedSubjectIdentifierFactory): |
| 50 | + def create_public_identifier(self, user_id): |
| 51 | + return user_id |
| 52 | + |
| 53 | + |
49 | 54 | class OpenIDConnectFrontend(FrontendModule): |
50 | 55 | """ |
51 | 56 | A OpenID Connect frontend module |
@@ -75,7 +80,10 @@ def __init__(self, auth_req_callback_func, internal_attributes, conf, base_url, |
75 | 80 | ) |
76 | 81 |
|
77 | 82 | sub_hash_salt = self.config.get("sub_hash_salt", rndstr(16)) |
78 | | - authz_state = _init_authorization_state(provider_config, db_uri, sub_hash_salt) |
| 83 | + mirror_public = self.config.get("sub_mirror_public", False) |
| 84 | + authz_state = _init_authorization_state( |
| 85 | + provider_config, db_uri, sub_hash_salt, mirror_public |
| 86 | + ) |
79 | 87 |
|
80 | 88 | client_db_uri = self.config.get("client_db_uri") |
81 | 89 | cdb_file = self.config.get("client_db_path") |
@@ -460,7 +468,9 @@ def _create_provider( |
460 | 468 | return provider |
461 | 469 |
|
462 | 470 |
|
463 | | -def _init_authorization_state(provider_config, db_uri, sub_hash_salt): |
| 471 | +def _init_authorization_state( |
| 472 | + provider_config, db_uri, sub_hash_salt, mirror_public=False |
| 473 | +): |
464 | 474 | if db_uri: |
465 | 475 | authz_code_db = StorageBase.from_uri( |
466 | 476 | db_uri, |
@@ -499,8 +509,14 @@ def _init_authorization_state(provider_config, db_uri, sub_hash_salt): |
499 | 509 | ] |
500 | 510 | if k in provider_config |
501 | 511 | } |
| 512 | + |
| 513 | + subject_id_factory = ( |
| 514 | + MirrorPublicSubjectIdentifierFactory(sub_hash_salt) |
| 515 | + if mirror_public |
| 516 | + else HashBasedSubjectIdentifierFactory(sub_hash_salt) |
| 517 | + ) |
502 | 518 | return AuthorizationState( |
503 | | - HashBasedSubjectIdentifierFactory(sub_hash_salt), |
| 519 | + subject_id_factory, |
504 | 520 | authz_code_db, |
505 | 521 | access_token_db, |
506 | 522 | refresh_token_db, |
|
0 commit comments