INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
return [channel] | def _get_initialized_channels_for_service(self, org_id, service_id):
'''return [channel]'''
channels_dict = self._get_initialized_channels_dict_for_service(org_id, service_id)
return list(channels_dict.values()) |
we make sure that MultiPartyEscrow address from metadata is correct | def _check_mpe_address_metadata(self, metadata):
""" we make sure that MultiPartyEscrow address from metadata is correct """
mpe_address = self.get_mpe_address()
if (str(mpe_address).lower() != str(metadata["mpe_address"]).lower()):
raise Exception("MultiPartyEscrow contract address ... |
similar to _init_or_update_service_if_needed but we get service_registraion from registry,
so we can update only registered services | def _init_or_update_registered_service_if_needed(self):
'''
similar to _init_or_update_service_if_needed but we get service_registraion from registry,
so we can update only registered services
'''
if (self.is_service_initialized()):
old_reg = self._read_service_info(s... |
read expiration from args.
We allow the following types of expirations
1. "<int>" simple integer defines absolute expiration in blocks
2. "+<int>blocks", where <int> is integer sets expiration as: current_block + <int>
3. "+<int>days", where <int> is integer sets expiration as: curren... | def _get_expiration_from_args(self):
"""
read expiration from args.
We allow the following types of expirations
1. "<int>" simple integer defines absolute expiration in blocks
2. "+<int>blocks", where <int> is integer sets expiration as: current_block + <int>
3. "+<int... |
- filter_by can be sender or signer | def _smart_get_initialized_channel_for_service(self, metadata, filter_by, is_try_initailize = True):
'''
- filter_by can be sender or signer
'''
channels = self._get_initialized_channels_for_service(self.args.org_id, self.args.service_id)
group_id = metadata.get_group_id(self.ar... |
return dict of lists rez[(<org_id>, <service_id>)] = [(channel_id, channel_info)] | def _get_all_initialized_channels(self):
""" return dict of lists rez[(<org_id>, <service_id>)] = [(channel_id, channel_info)] """
channels_dict = defaultdict(list)
for service_base_dir in self._get_persistent_mpe_dir().glob("*/*"):
org_id = service_base_dir.parent.name
... |
get all filtered chanels from blockchain logs | def _get_all_filtered_channels(self, topics_without_signature):
""" get all filtered chanels from blockchain logs """
mpe_address = self.get_mpe_address()
event_signature = self.ident.w3.sha3(text="ChannelOpen(uint256,uint256,address,address,address,bytes32,uint256,uint256)").hex()
t... |
We try to get config address from the different sources.
The order of priorioty is following:
- command line argument (at)
- command line argument (<contract_name>_at)
- current session configuration (current_<contract_name>_at)
- networks/*json | def get_contract_address(cmd, contract_name, error_message = None):
"""
We try to get config address from the different sources.
The order of priorioty is following:
- command line argument (at)
- command line argument (<contract_name>_at)
- current session configuration (current_<contract_name>... |
We try to get field_name from diffent sources:
The order of priorioty is following:
- command line argument (--<field_name>)
- current session configuration (default_<filed_name>) | def get_field_from_args_or_session(config, args, field_name):
"""
We try to get field_name from diffent sources:
The order of priorioty is following:
- command line argument (--<field_name>)
- current session configuration (default_<filed_name>)
"""
rez = getattr(args, field_name, None)
... |
Return element of abi (return None if fails to find) | def abi_get_element_by_name(abi, name):
""" Return element of abi (return None if fails to find) """
if (abi and "abi" in abi):
for a in abi["abi"]:
if ("name" in a and a["name"] == name):
return a
return None |
Just ensures the url has a scheme (http/https), and a net location (IP or domain name).
Can make more advanced or do on-network tests if needed, but this is really just to catch obvious errors.
>>> is_valid_endpoint("https://34.216.72.29:6206")
True
>>> is_valid_endpoint("blahblah")
False
>>> is... | def is_valid_endpoint(url):
"""
Just ensures the url has a scheme (http/https), and a net location (IP or domain name).
Can make more advanced or do on-network tests if needed, but this is really just to catch obvious errors.
>>> is_valid_endpoint("https://34.216.72.29:6206")
True
>>> is_valid_e... |
open grpc channel:
- for http:// we open insecure_channel
- for https:// we open secure_channel (with default credentials)
- without prefix we open insecure_channel | def open_grpc_channel(endpoint):
"""
open grpc channel:
- for http:// we open insecure_channel
- for https:// we open secure_channel (with default credentials)
- without prefix we open insecure_channel
"""
if (endpoint.startswith("https://")):
return grpc.sec... |
Creates a new Repo object in PFS with the given name. Repos are the
top level data object in PFS and should be used to store data of a
similar type. For example rather than having a single Repo for an
entire project you might have separate Repos for logs, metrics,
database dumps etc.
... | def create_repo(self, repo_name, description=None):
"""
Creates a new Repo object in PFS with the given name. Repos are the
top level data object in PFS and should be used to store data of a
similar type. For example rather than having a single Repo for an
entire project you mig... |
Returns info about a specific Repo.
Params:
* repo_name: Name of the repo. | def inspect_repo(self, repo_name):
"""
Returns info about a specific Repo.
Params:
* repo_name: Name of the repo.
"""
req = proto.InspectRepoRequest(repo=proto.Repo(name=repo_name))
res = self.stub.InspectRepo(req, metadata=self.metadata)
return r... |
Returns info about all Repos. | def list_repo(self):
"""
Returns info about all Repos.
"""
req = proto.ListRepoRequest()
res = self.stub.ListRepo(req, metadata=self.metadata)
if hasattr(res, 'repo_info'):
return res.repo_info
return [] |
Deletes a repo and reclaims the storage space it was using.
Params:
* repo_name: The name of the repo.
* force: If set to true, the repo will be removed regardless of
errors. This argument should be used with care.
* all: Delete all repos. | def delete_repo(self, repo_name=None, force=False, all=False):
"""
Deletes a repo and reclaims the storage space it was using.
Params:
* repo_name: The name of the repo.
* force: If set to true, the repo will be removed regardless of
errors. This argument should be used ... |
Begins the process of committing data to a Repo. Once started you can
write to the Commit with PutFile and when all the data has been
written you must finish the Commit with FinishCommit. NOTE, data is
not persisted until FinishCommit is called. A Commit object is
returned.
Para... | def start_commit(self, repo_name, branch=None, parent=None, description=None):
"""
Begins the process of committing data to a Repo. Once started you can
write to the Commit with PutFile and when all the data has been
written you must finish the Commit with FinishCommit. NOTE, data is
... |
Ends the process of committing data to a Repo and persists the
Commit. Once a Commit is finished the data becomes immutable and
future attempts to write to it with PutFile will error.
Params:
* commit: A tuple, string, or Commit object representing the commit. | def finish_commit(self, commit):
"""
Ends the process of committing data to a Repo and persists the
Commit. Once a Commit is finished the data becomes immutable and
future attempts to write to it with PutFile will error.
Params:
* commit: A tuple, string, or Commit objec... |
A context manager for doing stuff inside a commit. | def commit(self, repo_name, branch=None, parent=None, description=None):
"""A context manager for doing stuff inside a commit."""
commit = self.start_commit(repo_name, branch, parent, description)
try:
yield commit
except Exception as e:
print("An exception occurr... |
Returns info about a specific Commit.
Params:
* commit: A tuple, string, or Commit object representing the commit. | def inspect_commit(self, commit):
"""
Returns info about a specific Commit.
Params:
* commit: A tuple, string, or Commit object representing the commit.
"""
req = proto.InspectCommitRequest(commit=commit_from(commit))
return self.stub.InspectCommit(req, metadata=... |
Gets a list of CommitInfo objects.
Params:
* repo_name: If only `repo_name` is given, all commits in the repo are
returned.
* to_commit: Optional. Only the ancestors of `to`, including `to`
itself, are considered.
* from_commit: Optional. Only the descendants of `from`, ... | def list_commit(self, repo_name, to_commit=None, from_commit=None, number=0):
"""
Gets a list of CommitInfo objects.
Params:
* repo_name: If only `repo_name` is given, all commits in the repo are
returned.
* to_commit: Optional. Only the ancestors of `to`, including `to`... |
Deletes a commit.
Params:
* commit: A tuple, string, or Commit object representing the commit. | def delete_commit(self, commit):
"""
Deletes a commit.
Params:
* commit: A tuple, string, or Commit object representing the commit.
"""
req = proto.DeleteCommitRequest(commit=commit_from(commit))
self.stub.DeleteCommit(req, metadata=self.metadata) |
Blocks until all of the commits which have a set of commits as
provenance have finished. For commits to be considered they must have
all of the specified commits as provenance. This in effect waits for
all of the jobs that are triggered by a set of commits to complete.
It returns an erro... | def flush_commit(self, commits, repos=tuple()):
"""
Blocks until all of the commits which have a set of commits as
provenance have finished. For commits to be considered they must have
all of the specified commits as provenance. This in effect waits for
all of the jobs that are t... |
SubscribeCommit is like ListCommit but it keeps listening for commits as
they come in. This returns an iterator Commit objects.
Params:
* repo_name: Name of the repo.
* branch: Branch to subscribe to.
* from_commit_id: Optional. Only commits created since this commit
are... | def subscribe_commit(self, repo_name, branch, from_commit_id=None):
"""
SubscribeCommit is like ListCommit but it keeps listening for commits as
they come in. This returns an iterator Commit objects.
Params:
* repo_name: Name of the repo.
* branch: Branch to subscribe to... |
Lists the active Branch objects on a Repo.
Params:
* repo_name: The name of the repo. | def list_branch(self, repo_name):
"""
Lists the active Branch objects on a Repo.
Params:
* repo_name: The name of the repo.
"""
req = proto.ListBranchRequest(repo=proto.Repo(name=repo_name))
res = self.stub.ListBranch(req, metadata=self.metadata)
if hasat... |
Sets a commit and its ancestors as a branch.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* branch_name: The name for the branch to set. | def set_branch(self, commit, branch_name):
"""
Sets a commit and its ancestors as a branch.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* branch_name: The name for the branch to set.
"""
res = proto.SetBranchRequest(commit=commit_... |
Deletes a branch, but leaves the commits themselves intact. In other
words, those commits can still be accessed via commit IDs and other
branches they happen to be on.
Params:
* repo_name: The name of the repo.
* branch_name: The name of the branch to delete. | def delete_branch(self, repo_name, branch_name):
"""
Deletes a branch, but leaves the commits themselves intact. In other
words, those commits can still be accessed via commit IDs and other
branches they happen to be on.
Params:
* repo_name: The name of the repo.
... |
Uploads a binary bytes array as file(s) in a certain path.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* path: Path in the repo the file(s) will be written to.
* value: The file contents as bytes, represented as a file-like
object, bytestring, or... | def put_file_bytes(self, commit, path, value, delimiter=proto.NONE,
target_file_datums=0, target_file_bytes=0, overwrite_index=None):
"""
Uploads a binary bytes array as file(s) in a certain path.
Params:
* commit: A tuple, string, or Commit object representing th... |
Puts a file using the content found at a URL. The URL is sent to the
server which performs the request.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* path: The path to the file.
* url: The url of the file to put.
* recursive: allow for re... | def put_file_url(self, commit, path, url, recursive=False):
"""
Puts a file using the content found at a URL. The URL is sent to the
server which performs the request.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* path: The path to the fi... |
Returns an iterator of the contents contents of a file at a specific Commit.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* path: The path of the file.
* offset_bytes: Optional. specifies a number of bytes that should be
skipped in the beginning o... | def get_file(self, commit, path, offset_bytes=0, size_bytes=0, extract_value=True):
"""
Returns an iterator of the contents contents of a file at a specific Commit.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* path: The path of the file.
... |
Returns the contents of a list of files at a specific Commit as a
dictionary of file paths to data.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* paths: A list of paths to retrieve.
* recursive: If True, will go into each directory in the list
... | def get_files(self, commit, paths, recursive=False):
"""
Returns the contents of a list of files at a specific Commit as a
dictionary of file paths to data.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* paths: A list of paths to retrieve.... |
Returns info about a specific file.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* path: Path to file. | def inspect_file(self, commit, path):
"""
Returns info about a specific file.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* path: Path to file.
"""
req = proto.InspectFileRequest(file=proto.File(commit=commit_from(commit), path=pa... |
Lists the files in a directory.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* path: The path to the directory.
* recursive: If True, continue listing the files for sub-directories. | def list_file(self, commit, path, recursive=False):
"""
Lists the files in a directory.
Params:
* commit: A tuple, string, or Commit object representing the commit.
* path: The path to the directory.
* recursive: If True, continue listing the files for sub-directories.
... |
Deletes a file from a Commit. DeleteFile leaves a tombstone in the
Commit, assuming the file isn't written to later attempting to get the
file from the finished commit will result in not found error. The file
will of course remain intact in the Commit's parent.
Params:
* commit:... | def delete_file(self, commit, path):
"""
Deletes a file from a Commit. DeleteFile leaves a tombstone in the
Commit, assuming the file isn't written to later attempting to get the
file from the finished commit will result in not found error. The file
will of course remain intact i... |
See super class method satosa.frontends.base.FrontendModule#handle_authn_response
:type context: satosa.context.Context
:type internal_response: satosa.internal.InternalData
:rtype satosa.response.Response | def handle_authn_response(self, context, internal_response):
"""
See super class method satosa.frontends.base.FrontendModule#handle_authn_response
:type context: satosa.context.Context
:type internal_response: satosa.internal.InternalData
:rtype satosa.response.Response
"... |
This method is bound to the starting endpoint of the authentication.
:type context: satosa.context.Context
:type binding_in: str
:rtype: satosa.response.Response
:param context: The current context
:param binding_in: The binding type (http post, http redirect, ...)
:ret... | def handle_authn_request(self, context, binding_in):
"""
This method is bound to the starting endpoint of the authentication.
:type context: satosa.context.Context
:type binding_in: str
:rtype: satosa.response.Response
:param context: The current context
:param ... |
See super class satosa.frontends.base.FrontendModule
:type backend_names: list[str]
:rtype: list[(str, ((satosa.context.Context, Any) -> satosa.response.Response, Any))] | def register_endpoints(self, backend_names):
"""
See super class satosa.frontends.base.FrontendModule
:type backend_names: list[str]
:rtype: list[(str, ((satosa.context.Context, Any) -> satosa.response.Response, Any))]
"""
self.idp_config = self._build_idp_config_endpoint... |
Returns a dict containing the state needed in the response flow.
:type context: satosa.context.Context
:type resp_args: dict[str, str | saml2.samlp.NameIDPolicy]
:type relay_state: str
:rtype: dict[str, dict[str, str] | str]
:param context: The current context
:param re... | def _create_state_data(self, context, resp_args, relay_state):
"""
Returns a dict containing the state needed in the response flow.
:type context: satosa.context.Context
:type resp_args: dict[str, str | saml2.samlp.NameIDPolicy]
:type relay_state: str
:rtype: dict[str, d... |
Loads a state from state
:type state: satosa.state.State
:rtype: dict[str, Any]
:param state: The current state
:return: The dictionary given by the save_state function | def load_state(self, state):
"""
Loads a state from state
:type state: satosa.state.State
:rtype: dict[str, Any]
:param state: The current state
:return: The dictionary given by the save_state function
"""
state_data = state[self.name]
if isinstanc... |
Validates some parts of the module config
:type config: dict[str, dict[str, Any] | str]
:param config: The module config | def _validate_config(self, config):
"""
Validates some parts of the module config
:type config: dict[str, dict[str, Any] | str]
:param config: The module config
"""
required_keys = [
self.KEY_IDP_CONFIG,
self.KEY_ENDPOINTS,
]
if no... |
See doc for handle_authn_request method.
:type context: satosa.context.Context
:type binding_in: str
:type idp: saml.server.Server
:rtype: satosa.response.Response
:param context: The current context
:param binding_in: The pysaml binding type
:param idp: The sam... | def _handle_authn_request(self, context, binding_in, idp):
"""
See doc for handle_authn_request method.
:type context: satosa.context.Context
:type binding_in: str
:type idp: saml.server.Server
:rtype: satosa.response.Response
:param context: The current context... |
Returns a list of approved attributes
:type idp: saml.server.Server
:type idp_policy: saml2.assertion.Policy
:type sp_entity_id: str
:type state: satosa.state.State
:rtype: list[str]
:param idp: The saml frontend idp server
:param idp_policy: The idp policy
... | def _get_approved_attributes(self, idp, idp_policy, sp_entity_id, state):
"""
Returns a list of approved attributes
:type idp: saml.server.Server
:type idp_policy: saml2.assertion.Policy
:type sp_entity_id: str
:type state: satosa.state.State
:rtype: list[str]
... |
See super class satosa.frontends.base.FrontendModule
:type context: satosa.context.Context
:type internal_response: satosa.internal.InternalData
:type idp: saml.server.Server
:param context: The current context
:param internal_response: The internal response
:param idp:... | def _handle_authn_response(self, context, internal_response, idp):
"""
See super class satosa.frontends.base.FrontendModule
:type context: satosa.context.Context
:type internal_response: satosa.internal.InternalData
:type idp: saml.server.Server
:param context: The curr... |
See super class satosa.frontends.base.FrontendModule
:type exception: satosa.exception.SATOSAAuthenticationError
:type idp: saml.server.Server
:rtype: satosa.response.Response
:param exception: The SATOSAAuthenticationError
:param idp: The saml frontend idp server
:retu... | def _handle_backend_error(self, exception, idp):
"""
See super class satosa.frontends.base.FrontendModule
:type exception: satosa.exception.SATOSAAuthenticationError
:type idp: saml.server.Server
:rtype: satosa.response.Response
:param exception: The SATOSAAuthenticatio... |
Register methods to endpoints
:type providers: list[str]
:rtype: list[(str, ((satosa.context.Context, Any) -> satosa.response.Response, Any))]
:param providers: A list of backend providers
:return: A list of endpoint/method pairs | def _register_endpoints(self, providers):
"""
Register methods to endpoints
:type providers: list[str]
:rtype: list[(str, ((satosa.context.Context, Any) -> satosa.response.Response, Any))]
:param providers: A list of backend providers
:return: A list of endpoint/method pa... |
Builds the final frontend module config
:type config: dict[str, Any]
:type providers: list[str]
:rtype: dict[str, Any]
:param config: The module config
:param providers: A list of backend names
:return: The final config | def _build_idp_config_endpoints(self, config, providers):
"""
Builds the final frontend module config
:type config: dict[str, Any]
:type providers: list[str]
:rtype: dict[str, Any]
:param config: The module config
:param providers: A list of backend names
... |
Loads approved endpoints to the config.
:type url_base: str
:type provider: str
:type target_entity_id: str
:rtype: dict[str, Any]
:param url_base: The proxy base url
:param provider: target backend name
:param target_entity_id: frontend target entity id
... | def _load_endpoints_to_config(self, provider, target_entity_id, config=None):
"""
Loads approved endpoints to the config.
:type url_base: str
:type provider: str
:type target_entity_id: str
:rtype: dict[str, Any]
:param url_base: The proxy base url
:para... |
Loads an idp server that accepts the target backend name in the endpoint url
ex: /<backend_name>/sso/redirect
:type context: The current context
:rtype: saml.server.Server
:param context:
:return: An idp server | def _load_idp_dynamic_endpoints(self, context):
"""
Loads an idp server that accepts the target backend name in the endpoint url
ex: /<backend_name>/sso/redirect
:type context: The current context
:rtype: saml.server.Server
:param context:
:return: An idp serve... |
Loads an idp server with the entity id saved in state
:type state: satosa.state.State
:rtype: saml.server.Server
:param state: The current state
:return: An idp server | def _load_idp_dynamic_entity_id(self, state):
"""
Loads an idp server with the entity id saved in state
:type state: satosa.state.State
:rtype: saml.server.Server
:param state: The current state
:return: An idp server
"""
# Change the idp entity id dynam... |
Loads approved endpoints dynamically
See super class satosa.frontends.saml2.SAMLFrontend#handle_authn_request
:type context: satosa.context.Context
:type binding_in: str
:rtype: satosa.response.Response | def handle_authn_request(self, context, binding_in):
"""
Loads approved endpoints dynamically
See super class satosa.frontends.saml2.SAMLFrontend#handle_authn_request
:type context: satosa.context.Context
:type binding_in: str
:rtype: satosa.response.Response
"""... |
Adds the frontend idp entity id to state
See super class satosa.frontends.saml2.SAMLFrontend#save_state
:type context: satosa.context.Context
:type resp_args: dict[str, str | saml2.samlp.NameIDPolicy]
:type relay_state: str
:rtype: dict[str, dict[str, str] | str] | def _create_state_data(self, context, resp_args, relay_state):
"""
Adds the frontend idp entity id to state
See super class satosa.frontends.saml2.SAMLFrontend#save_state
:type context: satosa.context.Context
:type resp_args: dict[str, str | saml2.samlp.NameIDPolicy]
:ty... |
Loads the frontend entity id dynamically.
See super class satosa.frontends.saml2.SAMLFrontend#handle_backend_error
:type exception: satosa.exception.SATOSAAuthenticationError
:rtype: satosa.response.Response | def handle_backend_error(self, exception):
"""
Loads the frontend entity id dynamically.
See super class satosa.frontends.saml2.SAMLFrontend#handle_backend_error
:type exception: satosa.exception.SATOSAAuthenticationError
:rtype: satosa.response.Response
"""
idp =... |
See super class satosa.frontends.base.FrontendModule#handle_authn_response
:param context:
:param internal_response:
:return: | def handle_authn_response(self, context, internal_response):
"""
See super class satosa.frontends.base.FrontendModule#handle_authn_response
:param context:
:param internal_response:
:return:
"""
idp = self._load_idp_dynamic_entity_id(context.state)
return ... |
See super class satosa.frontends.base.FrontendModule#register_endpoints
:type providers: list[str]
:rtype list[(str, ((satosa.context.Context, Any) -> satosa.response.Response, Any))] |
list[(str, (satosa.context.Context) -> satosa.response.Response)]
:param providers: A list wit... | def _register_endpoints(self, providers):
"""
See super class satosa.frontends.base.FrontendModule#register_endpoints
:type providers: list[str]
:rtype list[(str, ((satosa.context.Context, Any) -> satosa.response.Response, Any))] |
list[(str, (satosa.context.Context) -> s... |
Adds the CO name to state
See super class satosa.frontends.saml2.SAMLFrontend#save_state
:type context: satosa.context.Context
:type resp_args: dict[str, str | saml2.samlp.NameIDPolicy]
:type relay_state: str
:rtype: dict[str, dict[str, str] | str] | def _create_state_data(self, context, resp_args, relay_state):
"""
Adds the CO name to state
See super class satosa.frontends.saml2.SAMLFrontend#save_state
:type context: satosa.context.Context
:type resp_args: dict[str, str | saml2.samlp.NameIDPolicy]
:type relay_state:... |
The CO name is URL encoded and obtained from the request path
for a request coming into one of the standard binding endpoints.
For example the HTTP-Redirect binding request path will have the
format
{base}/{backend}/{co_name}/sso/redirect
:type context: satosa.context.Context
... | def _get_co_name_from_path(self, context):
"""
The CO name is URL encoded and obtained from the request path
for a request coming into one of the standard binding endpoints.
For example the HTTP-Redirect binding request path will have the
format
{base}/{backend}/{co_name... |
Obtain the CO name previously saved in the request state, or if not set
use the request path obtained from the current context to determine
the target CO.
:type context: The current context
:rtype: string
:param context: The current context
:return: CO name | def _get_co_name(self, context):
"""
Obtain the CO name previously saved in the request state, or if not set
use the request path obtained from the current context to determine
the target CO.
:type context: The current context
:rtype: string
:param context: The ... |
Use the request path from the context to determine the target backend,
then construct mappings from bindings to endpoints for the virtual
IdP for the CO.
The endpoint URLs have the form
{base}/{backend}/{co_name}/{path}
:type config: satosa.satosa_config.SATOSAConfig
:... | def _add_endpoints_to_config(self, config, co_name, backend_name):
"""
Use the request path from the context to determine the target backend,
then construct mappings from bindings to endpoints for the virtual
IdP for the CO.
The endpoint URLs have the form
{base}/{backe... |
Use the CO name to construct the entity ID for the virtual IdP
for the CO.
The entity ID has the form
{base_entity_id}/{co_name}
:type config: satosa.satosa_config.SATOSAConfig
:type co_name: str
:rtype: satosa.satosa_config.SATOSAConfig
:param config: satosa ... | def _add_entity_id(self, config, co_name):
"""
Use the CO name to construct the entity ID for the virtual IdP
for the CO.
The entity ID has the form
{base_entity_id}/{co_name}
:type config: satosa.satosa_config.SATOSAConfig
:type co_name: str
:rtype: sa... |
Overlay configuration details like organization and contact person
from the front end configuration onto the IdP configuration to
support SAML metadata generation.
:type config: satosa.satosa_config.SATOSAConfig
:type co_name: str
:rtype: satosa.satosa_config.SATOSAConfig
... | def _overlay_for_saml_metadata(self, config, co_name):
"""
Overlay configuration details like organization and contact person
from the front end configuration onto the IdP configuration to
support SAML metadata generation.
:type config: satosa.satosa_config.SATOSAConfig
... |
Parse the configuration for the names of the COs for which to
construct virtual IdPs.
:rtype: [str]
:return: list of CO names | def _co_names_from_config(self):
"""
Parse the configuration for the names of the COs for which to
construct virtual IdPs.
:rtype: [str]
:return: list of CO names
"""
co_names = [co[self.KEY_ENCODEABLE_NAME] for
co in self.config[self.KEY_CO]... |
Create a virtual IdP to represent the CO.
:type context: The current context
:rtype: saml.server.Server
:param context:
:return: An idp server | def _create_co_virtual_idp(self, context):
"""
Create a virtual IdP to represent the CO.
:type context: The current context
:rtype: saml.server.Server
:param context:
:return: An idp server
"""
co_name = self._get_co_name(context)
context.decorat... |
See super class satosa.frontends.base.FrontendModule#register_endpoints
Endpoints have the format
{base}/{backend}/{co_name}/{binding path}
For example the HTTP-Redirect binding request path will have the
format
{base}/{backend}/{co_name}/sso/redirect
:type providers... | def _register_endpoints(self, backend_names):
"""
See super class satosa.frontends.base.FrontendModule#register_endpoints
Endpoints have the format
{base}/{backend}/{co_name}/{binding path}
For example the HTTP-Redirect binding request path will have the
format
... |
:param get_state: Generates a state to be used in authentication call
:type get_state: Callable[[str, bytes], str]
:type context: satosa.context.Context
:type internal_request: satosa.internal.InternalData
:rtype satosa.response.Redirect | def start_auth(self, context, internal_request, get_state=stateID):
"""
:param get_state: Generates a state to be used in authentication call
:type get_state: Callable[[str, bytes], str]
:type context: satosa.context.Context
:type internal_request: satosa.internal.InternalData
... |
Returns a SAML metadata entity (IdP) descriptor for a configured OAuth/OpenID Connect Backend.
:param entity_id: If entity_id is None, the id will be retrieved from the config
:type entity_id: str
:param config: The backend module config
:type config: dict[str, Any]
:return: metadata description
... | def get_metadata_desc_for_oauth_backend(entity_id, config):
"""
Returns a SAML metadata entity (IdP) descriptor for a configured OAuth/OpenID Connect Backend.
:param entity_id: If entity_id is None, the id will be retrieved from the config
:type entity_id: str
:param config: The backend module confi... |
See super class method satosa.backends.base#start_auth
:param get_state: Generates a state to be used in the authentication call.
:type get_state: Callable[[str, bytes], str]
:type context: satosa.context.Context
:type internal_request: satosa.internal.InternalData
:rtype satosa... | def start_auth(self, context, internal_request, get_state=stateID):
"""
See super class method satosa.backends.base#start_auth
:param get_state: Generates a state to be used in the authentication call.
:type get_state: Callable[[str, bytes], str]
:type context: satosa.context.Co... |
Will verify the state and throw and error if the state is invalid.
:type resp: AuthorizationResponse
:type state_data: dict[str, str]
:type state: satosa.state.State
:param resp: The authorization response from the AS, created by pyoidc.
:param state_data: The state data for thi... | def _verify_state(self, resp, state_data, state):
"""
Will verify the state and throw and error if the state is invalid.
:type resp: AuthorizationResponse
:type state_data: dict[str, str]
:type state: satosa.state.State
:param resp: The authorization response from the AS... |
Handles the authentication response from the AS.
:type context: satosa.context.Context
:rtype: satosa.response.Response
:param context: The context in SATOSA
:return: A SATOSA response. This method is only responsible to call the callback function
which generates the Response ob... | def _authn_response(self, context):
"""
Handles the authentication response from the AS.
:type context: satosa.context.Context
:rtype: satosa.response.Response
:param context: The context in SATOSA
:return: A SATOSA response. This method is only responsible to call the c... |
Will retrieve the user information data for the authenticated user.
:type access_token: str
:rtype: dict[str, str]
:param access_token: The access token to be used to retrieve the data.
:return: Dictionary with attribute name as key and attribute value as value. | def user_information(self, access_token):
"""
Will retrieve the user information data for the authenticated user.
:type access_token: str
:rtype: dict[str, str]
:param access_token: The access token to be used to retrieve the data.
:return: Dictionary with attribute name... |
Creates a SAML response.
:param binding: SAML response binding
:param http_args: http arguments
:return: response.Response | def make_saml_response(binding, http_args):
"""
Creates a SAML response.
:param binding: SAML response binding
:param http_args: http arguments
:return: response.Response
"""
if binding == BINDING_HTTP_REDIRECT:
headers = dict(http_args["headers"])
return SeeOther(str(headers... |
Hashes a value together with a salt with the given hash algorithm.
:type salt: str
:type hash_alg: str
:type value: str
:param salt: hash salt
:param hash_alg: the hash algorithm to use (default: SHA512)
:param value: value to hash together with the salt
:return: hashed value | def hash_data(salt, value, hash_alg=None):
"""
Hashes a value together with a salt with the given hash algorithm.
:type salt: str
:type hash_alg: str
:type value: str
:param salt: hash salt
:param hash_alg: the hash algorithm to use (default: SHA512)
:param value: value to hash together... |
Returns a string of random ascii characters or digits
:type size: int
:type alphabet: str
:param size: The length of the string
:param alphabet: A string with characters.
:return: string | def rndstr(size=16, alphabet=""):
"""
Returns a string of random ascii characters or digits
:type size: int
:type alphabet: str
:param size: The length of the string
:param alphabet: A string with characters.
:return: string
"""
rng = random.SystemRandom()
if not alphabet:
... |
Construct and return a LDAP directory search filter value from the
candidate identifier.
Argument 'canidate' is a dictionary with one required key and
two optional keys:
key required value
--------------- -------- ---------------------------------
attr... | def _construct_filter_value(self, candidate, data):
"""
Construct and return a LDAP directory search filter value from the
candidate identifier.
Argument 'canidate' is a dictionary with one required key and
two optional keys:
key required value
--... |
Filter sensitive details like passwords from a configuration
dictionary. | def _filter_config(self, config, fields=None):
"""
Filter sensitive details like passwords from a configuration
dictionary.
"""
filter_fields_default = [
'bind_password',
'connection'
]
filter_fields = fields or filter_fields_default
... |
Use the input configuration to instantiate and return
a ldap3 Connection object. | def _ldap_connection_factory(self, config):
"""
Use the input configuration to instantiate and return
a ldap3 Connection object.
"""
ldap_url = config['ldap_url']
bind_dn = config['bind_dn']
bind_password = config['bind_password']
if not ldap_url:
... |
Use a record found in LDAP to populate attributes. | def _populate_attributes(self, config, record, context, data):
"""
Use a record found in LDAP to populate attributes.
"""
search_return_attributes = config['search_return_attributes']
for attr in search_return_attributes.keys():
if attr in record["attributes"]:
... |
Use a record found in LDAP to populate input for
NameID generation. | def _populate_input_for_name_id(self, config, record, context, data):
"""
Use a record found in LDAP to populate input for
NameID generation.
"""
user_id = ""
user_id_from_attrs = config['user_id_from_attrs']
for attr in user_id_from_attrs:
if attr in ... |
Default interface for microservices. Process the input data for
the input context. | def process(self, context, data):
"""
Default interface for microservices. Process the input data for
the input context.
"""
self.context = context
# Find the entityID for the SP that initiated the flow.
try:
sp_entity_id = context.state.state_dict['S... |
:type data: dict[str, str]
:rtype: satosa.internal.AuthenticationInformation
:param data: A dict representation of an AuthenticationInformation object
:return: An AuthenticationInformation object | def from_dict(cls, data):
"""
:type data: dict[str, str]
:rtype: satosa.internal.AuthenticationInformation
:param data: A dict representation of an AuthenticationInformation object
:return: An AuthenticationInformation object
"""
return cls(
auth_class... |
Converts an InternalData object to a dict
:rtype: dict[str, str]
:return: A dict representation of the object | def to_dict(self):
"""
Converts an InternalData object to a dict
:rtype: dict[str, str]
:return: A dict representation of the object
"""
data = {
"auth_info": self.auth_info.to_dict(),
"requester": self.requester,
"requester_name": self... |
:type data: dict[str, str]
:rtype: satosa.internal.InternalData
:param data: A dict representation of an InternalData object
:return: An InternalData object | def from_dict(cls, data):
"""
:type data: dict[str, str]
:rtype: satosa.internal.InternalData
:param data: A dict representation of an InternalData object
:return: An InternalData object
"""
auth_info = AuthenticationInformation.from_dict(
data.get("au... |
Check that the configuration contains all necessary keys.
:type conf: dict
:rtype: None
:raise SATOSAConfigurationError: if the configuration is incorrect
:param conf: config to verify
:return: None | def _verify_dict(self, conf):
"""
Check that the configuration contains all necessary keys.
:type conf: dict
:rtype: None
:raise SATOSAConfigurationError: if the configuration is incorrect
:param conf: config to verify
:return: None
"""
if not co... |
Load config from yaml file or string
:type config_file: str
:rtype: dict
:param config_file: config to load. Can be file path or yaml string
:return: Loaded config | def _load_yaml(self, config_file):
"""
Load config from yaml file or string
:type config_file: str
:rtype: dict
:param config_file: config to load. Can be file path or yaml string
:return: Loaded config
"""
try:
with open(config_file) as f:
... |
Adds a session ID to the message.
:type logger: logging
:type level: int
:type message: str
:type state: satosa.state.State
:param logger: Logger to use
:param level: Logger level (ex: logging.DEBUG/logging.WARN/...)
:param message: Message
:param state: The current state
:param kw... | def satosa_logging(logger, level, message, state, **kwargs):
"""
Adds a session ID to the message.
:type logger: logging
:type level: int
:type message: str
:type state: satosa.state.State
:param logger: Logger to use
:param level: Logger level (ex: logging.DEBUG/logging.WARN/...)
... |
Will modify the context.target_backend attribute based on the requester identifier.
:param context: request context
:param data: the internal request | def process(self, context, data):
"""
Will modify the context.target_backend attribute based on the requester identifier.
:param context: request context
:param data: the internal request
"""
context.target_backend = self.requester_mapping[data.requester]
return s... |
Endpoint for handling consent service response
:type context: satosa.context.Context
:rtype: satosa.response.Response
:param context: response context
:return: response | def _handle_consent_response(self, context):
"""
Endpoint for handling consent service response
:type context: satosa.context.Context
:rtype: satosa.response.Response
:param context: response context
:return: response
"""
consent_state = context.state[STA... |
Manage consent and attribute filtering
:type context: satosa.context.Context
:type internal_response: satosa.internal.InternalData
:rtype: satosa.response.Response
:param context: response context
:param internal_response: the response
:return: response | def process(self, context, internal_response):
"""
Manage consent and attribute filtering
:type context: satosa.context.Context
:type internal_response: satosa.internal.InternalData
:rtype: satosa.response.Response
:param context: response context
:param interna... |
Get a hashed id based on requester, user id and filtered attributes
:type requester: str
:type user_id: str
:type filtered_attr: dict[str, str]
:param requester: The calling requester
:param user_id: The authorized user id
:param filtered_attr: a list containing all att... | def _get_consent_id(self, requester, user_id, filtered_attr):
"""
Get a hashed id based on requester, user id and filtered attributes
:type requester: str
:type user_id: str
:type filtered_attr: dict[str, str]
:param requester: The calling requester
:param user_... |
Register a request at the consent service
:type consent_args: dict
:rtype: str
:param consent_args: All necessary parameters for the consent request
:return: Ticket received from the consent service | def _consent_registration(self, consent_args):
"""
Register a request at the consent service
:type consent_args: dict
:rtype: str
:param consent_args: All necessary parameters for the consent request
:return: Ticket received from the consent service
"""
... |
Connects to the consent service using the REST api and checks if the user has given consent
:type consent_id: str
:rtype: Optional[List[str]]
:param consent_id: An id associated to the authenticated user, the calling requester and
attributes to be sent.
:return: list attributes... | def _verify_consent(self, consent_id):
"""
Connects to the consent service using the REST api and checks if the user has given consent
:type consent_id: str
:rtype: Optional[List[str]]
:param consent_id: An id associated to the authenticated user, the calling requester and
... |
Clear the state for consent and end the consent step
:type context: satosa.context.Context
:type internal_response: satosa.internal.InternalData
:rtype: satosa.response.Response
:param context: response context
:param internal_response: the response
:return: response | def _end_consent(self, context, internal_response):
"""
Clear the state for consent and end the consent step
:type context: satosa.context.Context
:type internal_response: satosa.internal.InternalData
:rtype: satosa.response.Response
:param context: response context
... |
Construct and return a primary identifier value from the
data asserted by the IdP using the ordered list of candidates
from the configuration. | def constructPrimaryIdentifier(self, data, ordered_identifier_candidates):
"""
Construct and return a primary identifier value from the
data asserted by the IdP using the ordered list of candidates
from the configuration.
"""
logprefix = PrimaryIdentifier.logprefix
... |
Saves a state to a cookie
:type state: satosa.state.State
:type name: str
:type path: str
:type encryption_key: str
:rtype: http.cookies.SimpleCookie
:param state: The state to save
:param name: Name identifier of the cookie
:param path: Endpoint path the cookie will be associated to
... | def state_to_cookie(state, name, path, encryption_key):
"""
Saves a state to a cookie
:type state: satosa.state.State
:type name: str
:type path: str
:type encryption_key: str
:rtype: http.cookies.SimpleCookie
:param state: The state to save
:param name: Name identifier of the cook... |
Loads a state from a cookie
:type cookie_str: str
:type name: str
:type encryption_key: str
:rtype: satosa.state.State
:param cookie_str: string representation of cookie/s
:param name: Name identifier of the cookie
:param encryption_key: Key to encrypt the state information
:return: A ... | def cookie_to_state(cookie_str, name, encryption_key):
"""
Loads a state from a cookie
:type cookie_str: str
:type name: str
:type encryption_key: str
:rtype: satosa.state.State
:param cookie_str: string representation of cookie/s
:param name: Name identifier of the cookie
:param e... |
Encryptes the parameter raw.
:type raw: bytes
:rtype: str
:param: bytes to be encrypted.
:return: A base 64 encoded string. | def encrypt(self, raw):
"""
Encryptes the parameter raw.
:type raw: bytes
:rtype: str
:param: bytes to be encrypted.
:return: A base 64 encoded string.
"""
raw = self._pad(raw)
iv = Random.new().read(AES.block_size)
cipher = AES.new(self... |
Will padd the param to be of the correct length for the encryption alg.
:type b: bytes
:rtype: bytes | def _pad(self, b):
"""
Will padd the param to be of the correct length for the encryption alg.
:type b: bytes
:rtype: bytes
"""
return b + (self.bs - len(b) % self.bs) * chr(self.bs - len(b) % self.bs).encode("UTF-8") |
Will return a url safe representation of the state.
:type encryption_key: Key used for encryption.
:rtype: str
:return: Url representation av of the state. | def urlstate(self, encryption_key):
"""
Will return a url safe representation of the state.
:type encryption_key: Key used for encryption.
:rtype: str
:return: Url representation av of the state.
"""
lzma = LZMACompressor()
urlstate_data = json.dumps(sel... |
Returns a deepcopy of the state
:rtype: satosa.state.State
:return: A copy of the state | def copy(self):
"""
Returns a deepcopy of the state
:rtype: satosa.state.State
:return: A copy of the state
"""
state_copy = State()
state_copy._state_dict = copy.deepcopy(self._state_dict)
return state_copy |
Translate pySAML2 name format to satosa format
:type name_format: str
:rtype: satosa.internal_data.UserIdHashType
:param name_format: SAML2 name format
:return: satosa format | def saml_name_id_format_to_hash_type(name_format):
"""
Translate pySAML2 name format to satosa format
:type name_format: str
:rtype: satosa.internal_data.UserIdHashType
:param name_format: SAML2 name format
:return: satosa format
"""
msg = "saml_name_id_format_to_hash_type is deprecated... |
Translate satosa format to pySAML2 name format
:type hash_type: satosa.internal_data.UserIdHashType
:rtype: str
:param hash_type: satosa format
:return: pySAML2 name format | def hash_type_to_saml_name_id_format(hash_type):
"""
Translate satosa format to pySAML2 name format
:type hash_type: satosa.internal_data.UserIdHashType
:rtype: str
:param hash_type: satosa format
:return: pySAML2 name format
"""
msg = "hash_type_to_saml_name_id_format is deprecated and... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.