functualize-secrets-aws 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- functualize_secrets_aws/__init__.py +196 -0
- functualize_secrets_aws/_reference.py +213 -0
- functualize_secrets_aws/_session.py +159 -0
- functualize_secrets_aws-0.4.0.dist-info/METADATA +65 -0
- functualize_secrets_aws-0.4.0.dist-info/RECORD +9 -0
- functualize_secrets_aws-0.4.0.dist-info/WHEEL +4 -0
- functualize_secrets_aws-0.4.0.dist-info/entry_points.txt +3 -0
- functualize_secrets_aws-0.4.0.dist-info/licenses/LICENSE +202 -0
- functualize_secrets_aws-0.4.0.dist-info/licenses/NOTICE +5 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""AWS remote configuration providers for functualize.
|
|
2
|
+
|
|
3
|
+
Two providers over one grammar:
|
|
4
|
+
|
|
5
|
+
* ``aws-sm`` — Secrets Manager (:class:`SecretsManagerProvider`)
|
|
6
|
+
* ``aws-ssm`` — SSM Parameter Store, including ``SecureString``
|
|
7
|
+
(:class:`ParameterStoreProvider`)
|
|
8
|
+
|
|
9
|
+
Both are registered through the ``functualize.remote_providers`` entry-point
|
|
10
|
+
group, which is what ``remote_first()`` refuses to boot without. They are
|
|
11
|
+
consulted by ``func builtin vault sync``, not during job execution: a run reads
|
|
12
|
+
the project's encrypted local vault and never touches the network (ADR-016).
|
|
13
|
+
|
|
14
|
+
`is_ready` and the protocol's 12-factor clause
|
|
15
|
+
----------------------------------------------
|
|
16
|
+
|
|
17
|
+
``RemoteProvider.is_ready``'s docstring says credentials "MUST be resolved from
|
|
18
|
+
environment variables only". This plugin does not honour that, deliberately and
|
|
19
|
+
on the maintainer's instruction: a single config file may need different
|
|
20
|
+
accounts, roles or profiles for different values, which is exactly what
|
|
21
|
+
environment variables cannot express. ``is_ready`` therefore reports whether
|
|
22
|
+
boto3 can find credentials *at all*, by any means in its chain. The divergence
|
|
23
|
+
is recorded here rather than left to be discovered in the diff.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
from typing import TYPE_CHECKING, Any
|
|
29
|
+
|
|
30
|
+
from functualize_secrets_aws._reference import (
|
|
31
|
+
HONOURED_KEYS,
|
|
32
|
+
AwsReference,
|
|
33
|
+
InvalidReferenceError,
|
|
34
|
+
parse_reference,
|
|
35
|
+
)
|
|
36
|
+
from functualize_secrets_aws._session import (
|
|
37
|
+
AccountMismatchError,
|
|
38
|
+
clear_credential_cache,
|
|
39
|
+
client_for,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if TYPE_CHECKING:
|
|
43
|
+
from collections.abc import Callable
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"HONOURED_KEYS",
|
|
47
|
+
"AccountMismatchError",
|
|
48
|
+
"AwsReference",
|
|
49
|
+
"InvalidReferenceError",
|
|
50
|
+
"ParameterStoreProvider",
|
|
51
|
+
"SecretNotFoundError",
|
|
52
|
+
"SecretsManagerProvider",
|
|
53
|
+
"clear_credential_cache",
|
|
54
|
+
"parse_reference",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class SecretNotFoundError(KeyError):
|
|
59
|
+
"""The reference parsed and the call succeeded, but nothing is there.
|
|
60
|
+
|
|
61
|
+
Distinct from :class:`InvalidReferenceError` (the annotation is wrong) and
|
|
62
|
+
from a connection failure (AWS could not be reached): this one means the
|
|
63
|
+
annotation is right and the secret has not been created.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class _AwsProvider:
|
|
68
|
+
"""Shared behaviour: parse, build a client, fetch, never log the value."""
|
|
69
|
+
|
|
70
|
+
#: Overridden by each subclass; also the entry-point key.
|
|
71
|
+
_identifier = ""
|
|
72
|
+
#: The boto3 service name this provider talks to.
|
|
73
|
+
_service = ""
|
|
74
|
+
|
|
75
|
+
def identifier(self) -> str:
|
|
76
|
+
return self._identifier
|
|
77
|
+
|
|
78
|
+
def is_ready(self) -> bool:
|
|
79
|
+
"""Whether boto3 can find any credentials.
|
|
80
|
+
|
|
81
|
+
Cached per instance: the answer involves the shared config files and,
|
|
82
|
+
as a last resort, instance metadata, and `sync` asks once per value.
|
|
83
|
+
"""
|
|
84
|
+
if self._ready is None:
|
|
85
|
+
try:
|
|
86
|
+
import boto3
|
|
87
|
+
|
|
88
|
+
self._ready = boto3.Session().get_credentials() is not None
|
|
89
|
+
except Exception:
|
|
90
|
+
self._ready = False
|
|
91
|
+
return self._ready
|
|
92
|
+
|
|
93
|
+
def __init__(self) -> None:
|
|
94
|
+
self._ready: bool | None = None
|
|
95
|
+
|
|
96
|
+
def fetch(self, reference: str) -> str:
|
|
97
|
+
"""Resolve one reference to its value.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
reference: Everything after ``aws-sm://`` or ``aws-ssm://``,
|
|
101
|
+
exactly as core passed it — opaque to core, parsed here.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
The value, as a string.
|
|
105
|
+
|
|
106
|
+
Raises:
|
|
107
|
+
InvalidReferenceError: The reference is malformed or names an
|
|
108
|
+
unknown override key.
|
|
109
|
+
AccountMismatchError: ``account`` was asserted and does not match.
|
|
110
|
+
SecretNotFoundError: The reference is valid and nothing is stored
|
|
111
|
+
under it.
|
|
112
|
+
"""
|
|
113
|
+
ref = parse_reference(reference)
|
|
114
|
+
return self._read(client_for(ref, self._service), ref)
|
|
115
|
+
|
|
116
|
+
def _read(self, client: Any, ref: AwsReference) -> str:
|
|
117
|
+
raise NotImplementedError
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _not_found(ref: AwsReference, what: str) -> SecretNotFoundError:
|
|
121
|
+
# The reference is safe to render -- it names where a value lives and
|
|
122
|
+
# carries no value (the same reasoning the vault's fall-through warning
|
|
123
|
+
# rests on). The value itself never appears in an error.
|
|
124
|
+
return SecretNotFoundError(f"No {what} named {ref.name!r} in AWS.")
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _guard_missing(
|
|
128
|
+
client: Any,
|
|
129
|
+
codes: tuple[str, ...],
|
|
130
|
+
call: Callable[[], Any],
|
|
131
|
+
ref: AwsReference,
|
|
132
|
+
what: str,
|
|
133
|
+
) -> Any:
|
|
134
|
+
"""Run an AWS call, turning its 'not found' codes into one exception.
|
|
135
|
+
|
|
136
|
+
Secrets Manager and Parameter Store spell absence differently
|
|
137
|
+
(``ResourceNotFoundException`` vs ``ParameterNotFound``), and botocore
|
|
138
|
+
builds those exception classes dynamically per client, so they are reached
|
|
139
|
+
through ``client.exceptions`` rather than imported.
|
|
140
|
+
"""
|
|
141
|
+
known = tuple(
|
|
142
|
+
getattr(client.exceptions, code)
|
|
143
|
+
for code in codes
|
|
144
|
+
if hasattr(client.exceptions, code)
|
|
145
|
+
)
|
|
146
|
+
try:
|
|
147
|
+
return call()
|
|
148
|
+
except known as exc: # type: ignore[misc]
|
|
149
|
+
raise _not_found(ref, what) from exc
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class SecretsManagerProvider(_AwsProvider):
|
|
153
|
+
"""``aws-sm://<secret-id>[?...]`` — AWS Secrets Manager."""
|
|
154
|
+
|
|
155
|
+
_identifier = "aws-sm"
|
|
156
|
+
_service = "secretsmanager"
|
|
157
|
+
|
|
158
|
+
def _read(self, client: Any, ref: AwsReference) -> str:
|
|
159
|
+
response = _guard_missing(
|
|
160
|
+
client,
|
|
161
|
+
("ResourceNotFoundException",),
|
|
162
|
+
lambda: client.get_secret_value(SecretId=ref.name),
|
|
163
|
+
ref,
|
|
164
|
+
"secret",
|
|
165
|
+
)
|
|
166
|
+
if "SecretString" in response:
|
|
167
|
+
return str(response["SecretString"])
|
|
168
|
+
# A binary secret has no faithful string form, and guessing an encoding
|
|
169
|
+
# would hand a job silently-wrong bytes.
|
|
170
|
+
raise InvalidReferenceError(
|
|
171
|
+
f"Secret {ref.name!r} holds binary data, which has no string form "
|
|
172
|
+
f"a config value can carry."
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class ParameterStoreProvider(_AwsProvider):
|
|
177
|
+
"""``aws-ssm://<parameter-name>[?...]`` — SSM Parameter Store.
|
|
178
|
+
|
|
179
|
+
``WithDecryption`` is always on. It is ignored for ``String`` and
|
|
180
|
+
``StringList``, so there is no knob to get wrong, and a ``SecureString``
|
|
181
|
+
read without it returns ciphertext — a value that would round-trip into the
|
|
182
|
+
vault and reach a job looking exactly like a secret while being useless.
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
_identifier = "aws-ssm"
|
|
186
|
+
_service = "ssm"
|
|
187
|
+
|
|
188
|
+
def _read(self, client: Any, ref: AwsReference) -> str:
|
|
189
|
+
response = _guard_missing(
|
|
190
|
+
client,
|
|
191
|
+
("ParameterNotFound", "ParameterVersionNotFound"),
|
|
192
|
+
lambda: client.get_parameter(Name=ref.name, WithDecryption=True),
|
|
193
|
+
ref,
|
|
194
|
+
"parameter",
|
|
195
|
+
)
|
|
196
|
+
return str(response["Parameter"]["Value"])
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"""The ``aws-sm://`` / ``aws-ssm://`` reference grammar.
|
|
2
|
+
|
|
3
|
+
Core treats everything after ``provider://`` as opaque and hands it to
|
|
4
|
+
``fetch()`` whole — including colons, slashes and query strings, pinned by
|
|
5
|
+
``TestTheReferenceIsOpaqueToCore``. This module is where that opaque string
|
|
6
|
+
acquires meaning, and it is the only place in the plugin that decides what a
|
|
7
|
+
reference *is*.
|
|
8
|
+
|
|
9
|
+
The grammar
|
|
10
|
+
-----------
|
|
11
|
+
|
|
12
|
+
::
|
|
13
|
+
|
|
14
|
+
aws-sm://<secret-id>[?<key>=<value>[&...]]
|
|
15
|
+
aws-ssm://<parameter-name>[?<key>=<value>[&...]]
|
|
16
|
+
|
|
17
|
+
``<secret-id>`` may be a name or a full ARN; ``<parameter-name>`` is an SSM
|
|
18
|
+
name, conventionally leading-slash. Both are passed to AWS verbatim.
|
|
19
|
+
|
|
20
|
+
Why splitting on ``?`` is safe: neither an SSM parameter name
|
|
21
|
+
(``[a-zA-Z0-9_.\\-/]``) nor an ARN admits a literal ``?``, so the first ``?``
|
|
22
|
+
can only begin the override block.
|
|
23
|
+
|
|
24
|
+
Four override keys, and why each behaves as it does
|
|
25
|
+
---------------------------------------------------
|
|
26
|
+
|
|
27
|
+
Different secrets in one config file may legitimately need different accounts,
|
|
28
|
+
roles or profiles, so the override is per *value*, not per provider.
|
|
29
|
+
|
|
30
|
+
``profile``
|
|
31
|
+
Selects a named profile from the shared AWS config, replacing the ambient
|
|
32
|
+
credential chain for this value.
|
|
33
|
+
|
|
34
|
+
``role``
|
|
35
|
+
An IAM role ARN to assume. Composes with ``profile``: the profile (or the
|
|
36
|
+
ambient chain) supplies the *source* identity, and the role is assumed from
|
|
37
|
+
it. The resulting temporary credentials live in memory for the life of the
|
|
38
|
+
process and are **never** persisted — see :mod:`functualize_secrets_aws._session`.
|
|
39
|
+
|
|
40
|
+
``region``
|
|
41
|
+
The region the client is built for.
|
|
42
|
+
|
|
43
|
+
``account``
|
|
44
|
+
An **assertion**, not a selector. boto3 has no "switch to account N"
|
|
45
|
+
primitive, so a key named ``account`` can only mean one of two things:
|
|
46
|
+
silently ignored, or checked. Checked — the resolved caller identity must
|
|
47
|
+
match, and a mismatch raises. Reading the *wrong account's* secret while
|
|
48
|
+
believing you named the right one is the failure this whole feature exists
|
|
49
|
+
to prevent.
|
|
50
|
+
|
|
51
|
+
An unknown key is rejected, never ignored. ``?porfile=prod-admin`` silently
|
|
52
|
+
resolving under the default identity is the same class of defect as
|
|
53
|
+
``remote_first()`` silently behaving as ``classic()``: the caller states an
|
|
54
|
+
intent, and the system quietly does something else.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
from __future__ import annotations
|
|
58
|
+
|
|
59
|
+
import difflib
|
|
60
|
+
import re
|
|
61
|
+
from dataclasses import dataclass
|
|
62
|
+
from urllib.parse import unquote
|
|
63
|
+
|
|
64
|
+
__all__ = [
|
|
65
|
+
"HONOURED_KEYS",
|
|
66
|
+
"AwsReference",
|
|
67
|
+
"InvalidReferenceError",
|
|
68
|
+
"parse_reference",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
#: The override keys this provider understands. Anything else is an error.
|
|
72
|
+
HONOURED_KEYS: tuple[str, ...] = ("account", "profile", "region", "role")
|
|
73
|
+
|
|
74
|
+
#: 12 digits, the fixed shape of an AWS account id.
|
|
75
|
+
_ACCOUNT_RE = re.compile(r"^\d{12}$")
|
|
76
|
+
|
|
77
|
+
#: `us-east-1`, `eu-west-2`, `ap-southeast-2`, and the partitioned forms
|
|
78
|
+
#: `us-gov-west-1` / `cn-north-1`. Deliberately a shape check, not a list:
|
|
79
|
+
#: AWS adds regions faster than a pinned list can follow, and the cost of the
|
|
80
|
+
#: check is only to turn a typo into a clear error instead of a boto3 one.
|
|
81
|
+
_REGION_RE = re.compile(r"^[a-z]{2}(?:-[a-z]+)+-\d+$")
|
|
82
|
+
|
|
83
|
+
#: An IAM *role* ARN. A bare role name here is the common mistake and fails
|
|
84
|
+
#: inside STS with a message that does not mention the annotation.
|
|
85
|
+
_ROLE_ARN_RE = re.compile(r"^arn:aws[a-z-]*:iam::\d{12}:role/\S+$")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class InvalidReferenceError(ValueError):
|
|
89
|
+
"""A reference this provider cannot make sense of.
|
|
90
|
+
|
|
91
|
+
Raised at parse time, before any AWS call, so a typo costs a clear message
|
|
92
|
+
rather than a confusing API error or — worse — a silent resolution under
|
|
93
|
+
the wrong identity.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@dataclass(frozen=True)
|
|
98
|
+
class AwsReference:
|
|
99
|
+
"""A parsed reference: what to fetch, and whose credentials to fetch it with."""
|
|
100
|
+
|
|
101
|
+
name: str
|
|
102
|
+
"""The secret id or parameter name, passed to AWS verbatim."""
|
|
103
|
+
|
|
104
|
+
profile: str | None = None
|
|
105
|
+
region: str | None = None
|
|
106
|
+
role: str | None = None
|
|
107
|
+
account: str | None = None
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def identity_key(self) -> tuple[str | None, str | None, str | None]:
|
|
111
|
+
"""What distinguishes one credential resolution from another.
|
|
112
|
+
|
|
113
|
+
``name`` is deliberately absent: two secrets fetched with the same
|
|
114
|
+
profile, role and region share a session, which is what makes an
|
|
115
|
+
assume-role cache worth having.
|
|
116
|
+
"""
|
|
117
|
+
return (self.profile, self.role, self.region)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _fail(reference: str, detail: str) -> InvalidReferenceError:
|
|
121
|
+
return InvalidReferenceError(f"{detail}\n in reference: {reference!r}")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _suggest(key: str) -> str:
|
|
125
|
+
"""Name the intended key when a typo is close enough to guess."""
|
|
126
|
+
close = difflib.get_close_matches(key, HONOURED_KEYS, n=1, cutoff=0.6)
|
|
127
|
+
return f" Did you mean '{close[0]}'?" if close else ""
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _split_pairs(query: str, reference: str) -> list[tuple[str, str]]:
|
|
131
|
+
"""Split the override block into key/value pairs.
|
|
132
|
+
|
|
133
|
+
Hand-rolled rather than :func:`urllib.parse.parse_qsl` because that decodes
|
|
134
|
+
``+`` as a space. None of the four values may contain a space, so a role
|
|
135
|
+
ARN or profile name carrying a ``+`` would be silently corrupted into one
|
|
136
|
+
that does — a wrong-identity failure produced by the parser itself.
|
|
137
|
+
"""
|
|
138
|
+
pairs: list[tuple[str, str]] = []
|
|
139
|
+
for chunk in query.split("&"):
|
|
140
|
+
if not chunk:
|
|
141
|
+
raise _fail(reference, "Empty entry in the override block.")
|
|
142
|
+
key, sep, value = chunk.partition("=")
|
|
143
|
+
if not sep:
|
|
144
|
+
raise _fail(reference, f"Override {chunk!r} is missing a '=' and a value.")
|
|
145
|
+
pairs.append((unquote(key).strip(), unquote(value).strip()))
|
|
146
|
+
return pairs
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def parse_reference(reference: str) -> AwsReference:
|
|
150
|
+
"""Parse an ``aws-sm``/``aws-ssm`` reference into its parts.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
reference: Everything after ``provider://``, exactly as core passed it.
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
The parsed reference.
|
|
157
|
+
|
|
158
|
+
Raises:
|
|
159
|
+
InvalidReferenceError: The name is empty, an override key is unknown or
|
|
160
|
+
repeated, or a value does not have the shape its key requires.
|
|
161
|
+
"""
|
|
162
|
+
name, _, query = reference.partition("?")
|
|
163
|
+
if not name:
|
|
164
|
+
raise _fail(reference, "No secret id or parameter name before the '?'.")
|
|
165
|
+
|
|
166
|
+
values: dict[str, str] = {}
|
|
167
|
+
if query:
|
|
168
|
+
for key, value in _split_pairs(query, reference):
|
|
169
|
+
if key not in HONOURED_KEYS:
|
|
170
|
+
raise _fail(
|
|
171
|
+
reference,
|
|
172
|
+
f"Unknown override '{key}'.{_suggest(key)} "
|
|
173
|
+
f"Honoured keys: {', '.join(HONOURED_KEYS)}.",
|
|
174
|
+
)
|
|
175
|
+
if key in values:
|
|
176
|
+
raise _fail(
|
|
177
|
+
reference,
|
|
178
|
+
f"Override '{key}' given more than once; which one wins is "
|
|
179
|
+
f"not something this grammar should have to guess.",
|
|
180
|
+
)
|
|
181
|
+
if not value:
|
|
182
|
+
raise _fail(reference, f"Override '{key}' has an empty value.")
|
|
183
|
+
values[key] = value
|
|
184
|
+
|
|
185
|
+
account = values.get("account")
|
|
186
|
+
if account is not None and not _ACCOUNT_RE.match(account):
|
|
187
|
+
raise _fail(reference, f"'account' must be 12 digits, got {account!r}.")
|
|
188
|
+
|
|
189
|
+
region = values.get("region")
|
|
190
|
+
if region is not None and not _REGION_RE.match(region):
|
|
191
|
+
raise _fail(
|
|
192
|
+
reference,
|
|
193
|
+
f"'region' does not look like an AWS region, got {region!r} "
|
|
194
|
+
f"(expected e.g. 'us-east-1', 'eu-west-2', 'us-gov-west-1').",
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
role = values.get("role")
|
|
198
|
+
if role is not None and not _ROLE_ARN_RE.match(role):
|
|
199
|
+
raise _fail(
|
|
200
|
+
reference,
|
|
201
|
+
f"'role' must be a full IAM role ARN, got {role!r} "
|
|
202
|
+
f"(expected e.g. 'arn:aws:iam::123456789012:role/Deploy'). "
|
|
203
|
+
f"A bare role name fails inside STS with a message that never "
|
|
204
|
+
f"mentions this annotation.",
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
return AwsReference(
|
|
208
|
+
name=name,
|
|
209
|
+
profile=values.get("profile"),
|
|
210
|
+
region=region,
|
|
211
|
+
role=role,
|
|
212
|
+
account=account,
|
|
213
|
+
)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""Turning a parsed reference into a boto3 client.
|
|
2
|
+
|
|
3
|
+
Three things happen here, in this order, and the order is the contract:
|
|
4
|
+
|
|
5
|
+
1. **Source identity.** ``profile`` selects a named profile; without it, the
|
|
6
|
+
ambient boto3 chain applies unchanged.
|
|
7
|
+
2. **Role assumption.** ``role`` is assumed *from* whatever step 1 produced, so
|
|
8
|
+
the two compose rather than conflict.
|
|
9
|
+
3. **Account assertion.** ``account`` is checked against the identity that
|
|
10
|
+
actually resulted, after any assumption. Checking before step 2 would
|
|
11
|
+
assert the wrong thing.
|
|
12
|
+
|
|
13
|
+
Where the temporary credentials live
|
|
14
|
+
------------------------------------
|
|
15
|
+
|
|
16
|
+
In memory, in :data:`_ASSUMED`, for the life of the process. They are never
|
|
17
|
+
written to disk and they never enter the vault: the vault holds resolved
|
|
18
|
+
*values*, and a credential is not one. Structurally this is guaranteed by the
|
|
19
|
+
seam rather than by care — the vault is filled from what ``fetch()`` returns,
|
|
20
|
+
and ``fetch()`` returns the secret string.
|
|
21
|
+
|
|
22
|
+
The cache is keyed by ``(profile, role, region)`` and honoured until five
|
|
23
|
+
minutes before expiry, so a sync fetching thirty secrets under one role calls
|
|
24
|
+
STS once rather than thirty times.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from __future__ import annotations
|
|
28
|
+
|
|
29
|
+
import threading
|
|
30
|
+
from dataclasses import dataclass
|
|
31
|
+
from datetime import UTC, datetime, timedelta
|
|
32
|
+
from typing import TYPE_CHECKING, Any
|
|
33
|
+
|
|
34
|
+
import boto3
|
|
35
|
+
|
|
36
|
+
if TYPE_CHECKING:
|
|
37
|
+
from functualize_secrets_aws._reference import AwsReference
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"AccountMismatchError",
|
|
41
|
+
"client_for",
|
|
42
|
+
"clear_credential_cache",
|
|
43
|
+
"resolve_session",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
#: Re-assume this long before the credentials actually expire, so a long sync
|
|
47
|
+
#: cannot start a fetch with credentials that die mid-call.
|
|
48
|
+
_EXPIRY_MARGIN = timedelta(minutes=5)
|
|
49
|
+
|
|
50
|
+
_SESSION_NAME = "functualize-config-sync"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class AccountMismatchError(RuntimeError):
|
|
54
|
+
"""The resolved identity is not in the account the reference asserted.
|
|
55
|
+
|
|
56
|
+
Loud by design. The alternative — carrying on — means reading some *other*
|
|
57
|
+
account's secret while the config file says which account was meant.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclass(frozen=True)
|
|
62
|
+
class _Assumed:
|
|
63
|
+
credentials: dict[str, Any]
|
|
64
|
+
expires_at: datetime
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def usable(self) -> bool:
|
|
68
|
+
return datetime.now(UTC) + _EXPIRY_MARGIN < self.expires_at
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
_ASSUMED: dict[tuple[str | None, str | None, str | None], _Assumed] = {}
|
|
72
|
+
_LOCK = threading.Lock()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def clear_credential_cache() -> None:
|
|
76
|
+
"""Drop every cached assumption. For tests, and for a long-lived process
|
|
77
|
+
that has just been told its role changed."""
|
|
78
|
+
with _LOCK:
|
|
79
|
+
_ASSUMED.clear()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _base_session(ref: AwsReference) -> boto3.Session:
|
|
83
|
+
"""Step 1: the source identity, before any role is assumed."""
|
|
84
|
+
kwargs: dict[str, Any] = {}
|
|
85
|
+
if ref.profile is not None:
|
|
86
|
+
kwargs["profile_name"] = ref.profile
|
|
87
|
+
if ref.region is not None:
|
|
88
|
+
kwargs["region_name"] = ref.region
|
|
89
|
+
return boto3.Session(**kwargs)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _assume(ref: AwsReference, base: boto3.Session) -> _Assumed:
|
|
93
|
+
sts = base.client("sts")
|
|
94
|
+
response = sts.assume_role(RoleArn=ref.role, RoleSessionName=_SESSION_NAME)
|
|
95
|
+
creds = response["Credentials"]
|
|
96
|
+
return _Assumed(
|
|
97
|
+
credentials={
|
|
98
|
+
"aws_access_key_id": creds["AccessKeyId"],
|
|
99
|
+
"aws_secret_access_key": creds["SecretAccessKey"],
|
|
100
|
+
"aws_session_token": creds["SessionToken"],
|
|
101
|
+
},
|
|
102
|
+
expires_at=creds["Expiration"],
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def resolve_session(ref: AwsReference) -> boto3.Session:
|
|
107
|
+
"""Build the session this reference's credentials describe.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
ref: The parsed reference.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
A session carrying the source identity, or the assumed role's
|
|
114
|
+
temporary credentials when ``role`` is set.
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
AccountMismatchError: ``account`` was asserted and does not match.
|
|
118
|
+
"""
|
|
119
|
+
base = _base_session(ref)
|
|
120
|
+
session = base
|
|
121
|
+
|
|
122
|
+
if ref.role is not None:
|
|
123
|
+
key = ref.identity_key
|
|
124
|
+
with _LOCK:
|
|
125
|
+
cached = _ASSUMED.get(key)
|
|
126
|
+
if cached is None or not cached.usable:
|
|
127
|
+
cached = _assume(ref, base)
|
|
128
|
+
_ASSUMED[key] = cached
|
|
129
|
+
session = boto3.Session(
|
|
130
|
+
region_name=ref.region or base.region_name, **cached.credentials
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
if ref.account is not None:
|
|
134
|
+
_assert_account(session, ref)
|
|
135
|
+
|
|
136
|
+
return session
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _assert_account(session: boto3.Session, ref: AwsReference) -> None:
|
|
140
|
+
identity = session.client("sts").get_caller_identity()
|
|
141
|
+
actual = identity.get("Account")
|
|
142
|
+
if actual != ref.account:
|
|
143
|
+
raise AccountMismatchError(
|
|
144
|
+
f"Reference asserts account {ref.account}, but the resolved "
|
|
145
|
+
f"identity is in account {actual} "
|
|
146
|
+
f"(arn: {identity.get('Arn')}).\n"
|
|
147
|
+
f" reference: {ref.name!r}\n"
|
|
148
|
+
f"Refusing rather than reading a different account's value."
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def client_for(ref: AwsReference, service: str) -> Any:
|
|
153
|
+
"""A client for ``service``, built for this reference's identity.
|
|
154
|
+
|
|
155
|
+
``AWS_ENDPOINT_URL`` is honoured by botocore itself, which is what lets the
|
|
156
|
+
integration tests point at a local emulator without this plugin knowing
|
|
157
|
+
anything about one.
|
|
158
|
+
"""
|
|
159
|
+
return resolve_session(ref).client(service)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: functualize-secrets-aws
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: AWS Secrets Manager and SSM Parameter Store providers for functualize
|
|
5
|
+
Author-email: Mohammad Hakim Adiprasetya <viltohmyst@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: NOTICE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: boto3>=1.34.0
|
|
17
|
+
Requires-Dist: functualize<1.0.0,>=0.1.0
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# functualize-secrets-aws
|
|
24
|
+
|
|
25
|
+
AWS Secrets Manager (`aws-sm`) and SSM Parameter Store (`aws-ssm`) providers
|
|
26
|
+
for functualize's remote configuration layer.
|
|
27
|
+
|
|
28
|
+
```toml
|
|
29
|
+
[database]
|
|
30
|
+
password = "aws-sm://prod/db-password"
|
|
31
|
+
replica = "aws-sm://prod/db?account=123456789012®ion=eu-west-1"
|
|
32
|
+
api_url = "aws-ssm:///prod/api-url"
|
|
33
|
+
token = "aws-ssm:///prod/api-token?role=arn:aws:iam::123456789012:role/Deploy"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Values are fetched by `func builtin vault sync` and stored in the project's
|
|
37
|
+
encrypted local vault. Job execution reads the vault, never the network
|
|
38
|
+
(ADR-016).
|
|
39
|
+
|
|
40
|
+
## Override keys
|
|
41
|
+
|
|
42
|
+
| Key | Meaning |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `profile` | Named profile from the shared AWS config; replaces the ambient chain for this value. |
|
|
45
|
+
| `role` | IAM role ARN to assume. Composes with `profile`, which supplies the source identity. |
|
|
46
|
+
| `region` | Region the client is built for. |
|
|
47
|
+
| `account` | **Assertion**, not a selector: the resolved caller identity must match, or the fetch fails. |
|
|
48
|
+
|
|
49
|
+
An unknown key is an error, not a no-op — `?porfile=prod` must not resolve
|
|
50
|
+
quietly under the default identity.
|
|
51
|
+
|
|
52
|
+
Temporary credentials from `role` live in memory for the life of the process.
|
|
53
|
+
They are never written to disk and never enter the vault, which holds resolved
|
|
54
|
+
values, not credentials.
|
|
55
|
+
|
|
56
|
+
## Testing against a local emulator
|
|
57
|
+
|
|
58
|
+
Set `AWS_ENDPOINT_URL` and any LocalStack-compatible emulator works:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
docker run -d --name floci -p 4566:4566 floci/floci:latest
|
|
62
|
+
AWS_ENDPOINT_URL=http://localhost:4566 uv run pytest plugins/credentials/functualize-secrets-aws
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Without it the integration tests skip.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
functualize_secrets_aws/__init__.py,sha256=h6rWANRpgNBFExtROpZy_s3iucBaX-KBkpbYGVlwVIc,6689
|
|
2
|
+
functualize_secrets_aws/_reference.py,sha256=vDZ4mDOzqcC3iTb-Bedc7PFuB56KZs_kOjWYIc7yuuM,7973
|
|
3
|
+
functualize_secrets_aws/_session.py,sha256=OdXCwv_auylHmXPfF35U_8sWKS3pPJVnBzhDhl-pzlk,5204
|
|
4
|
+
functualize_secrets_aws-0.4.0.dist-info/METADATA,sha256=qrigysdu1GvWOmGzv7MfVhzmcgkPfk-_NUk4XO8VucE,2376
|
|
5
|
+
functualize_secrets_aws-0.4.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
6
|
+
functualize_secrets_aws-0.4.0.dist-info/entry_points.txt,sha256=Nz8V9nV6ZI7_p6zNIpua_IB4GdRGEYGnvgYOxsWhzgM,144
|
|
7
|
+
functualize_secrets_aws-0.4.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
8
|
+
functualize_secrets_aws-0.4.0.dist-info/licenses/NOTICE,sha256=KJFeVuX_Ca8unbdlNIpqyYcZTM9p5A3CBNBlb3bnKhs,176
|
|
9
|
+
functualize_secrets_aws-0.4.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|