Skip to content

Commit 054e633

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 3068e98 + 2fdc0fd commit 054e633

File tree

8 files changed

+222
-82
lines changed

8 files changed

+222
-82
lines changed

README.md

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Limes
22
Limes provides an easy work flow with MFA protected access keys, temporary credentials and access to multiple roles/accounts.
33

4-
Limes is a Local Instance MEtadata Service and emulates parts of the [AWS Instance Metadata Service](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) running on Amazon Linux. The AWS SDK and AWS CLI can therefor utilize this service to authenticate.
4+
Limes is the Local Instance MEtadata Service and emulates parts of the [AWS Instance Metadata Service](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) running on Amazon Linux. The AWS SDK and AWS CLI can therefor utilize this service to authenticate.
55

66
## Warning
77
The AWS SDK refreshes credentials automatically when using limes. So **all** services will change profile if the profile is changed in limes.
@@ -30,6 +30,31 @@ sudo ip link set dev lo:metadata up
3030
sudo /sbin/ifconfig lo0 alias 169.254.169.254
3131
```
3232

33+
## Bash Completion
34+
35+
##### Linux:
36+
```
37+
wget -O /etc/bash_completion.d/limes https://raw.githubusercontent.com/otm/limes/master/assets/limes
38+
```
39+
40+
##### Mac
41+
```
42+
wget -O $(brew --prefix)/etc/bash_completion.d/limes https://raw.githubusercontent.com/otm/limes/master/assets/limes
43+
```
44+
45+
##### Fixing Completion for AWS CLI
46+
There is currently a bug in the completer for the AWS CLI that makes it misbehave when used with `_command_offset`. This can be solved by adding a secondary completion entry for the AWS CLI. To make this persistent add it to your bash configuration.
47+
48+
**Linux**
49+
```
50+
complete -C '/usr/local/bin/aws_completer' limes run aws
51+
```
52+
53+
**Mac (Brew)**
54+
```
55+
complete -C "$(brew --prefix)/bin/aws_completer" limes run aws
56+
```
57+
3358
## Configuring IAM (Identity and Access Management)
3459
To be done
3560

@@ -50,26 +75,33 @@ Running `limes` in your terminal prints usage information.
5075
The service is started with `limes start`.
5176

5277
#### Assuming Profiles
53-
A profile is assumed with `limes profile <profile-name>`, where profile-name is
54-
a configured profile. Please note that this does not refer to AWS profiles but
55-
profiles configured in limes.
78+
A profile is assumed with `limes assume <profile-name>`, where profile-name is a configured profile. Please note that this does not refer to AWS profiles but profiles configured in limes.
79+
80+
#### Running Applications with Alternate Profile
81+
If you have assumed a role on limes you might want to run an application once with an alternate profile. This is possible without assuming the profile with the `run` subcommand.
82+
83+
```
84+
limes --profile <name> run <application> [args...]
85+
```
86+
87+
**Tip**
88+
With `limes --profile <name> run bash` it is possible to quickly start a shell with exported environment variables that is valid for an hour.
89+
90+
#### Protected Profiles
91+
By adding `protected: true` to your profile it will not be possible to assume that role. It will only be possible to utilize the subcommands `run` and `env`.
5692

5793
#### Service Status
58-
By running `limes status` it is possible to see the current status, and also it can detect common problems and misconfigurations.
94+
By running `limes status` it is possible to see the current status, and also it can detect common problems and misconfiguration.
5995

6096
## Known Problems
61-
If AWS environment variables, `.aws/credentials` or `.aws/config` are present there is a chance that the limes does not work. This can be checked with `limes status`
97+
If AWS environment variables, `.aws/credentials` or `.aws/config` are present there is a chance that the limes does not work. This can be checked with `limes status`.
6298

6399
## Security
64100
The service should be configured on the loop back device, and only accessible from the host it is running on.
65101

66102
**Note:** It is important not to run any service that could forwards request on the host running Limes as this would be a security risk. However, this is no difference from the setup on an Amazon Linux instance in AWS. If an attacker could forward requests to 169.254.169.254/24 your credentials could be compromised. Please note that an attacker could utilize a DNS to resolve to this address, so always be aware where you forward requests to.
67103

68104
## Roadmap
69-
* Add support for running commands
70-
* Add support for providing MFA with client to enable to start as a service
71-
* Add support for temporary move/remove AWS configuration files
72-
* Add support for exporting environment variables
73105
* Windows support (If I get someone to test it)
74106

75107
## Build

assets/limes

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
# bash completion for limes(8) -*- shell-script -*-
22

3+
__my_init_completion()
4+
{
5+
COMPREPLY=()
6+
_get_comp_words_by_ref cur prev words cword
7+
}
8+
9+
10+
311
_limes()
412
{
513
local cur prev words cword
6-
_init_completion || return
14+
if declare -F _init_completions >/dev/null 2>&1; then
15+
_init_completion
16+
else
17+
__my_init_completion
18+
fi
19+
#_init_completion || return
720

821
#cur="${COMP_WORDS[COMP_CWORD]}"
922
#prev="${COMP_WORDS[COMP_CWORD-1]}"

cli-client.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,21 @@ func StartService(configFile, address, profileName, MFA string, port int, fake b
6767
log.Fatalf("Error reading config: %s\n", configErr.Error())
6868
}
6969

70-
configParseErr := yaml.Unmarshal(configContents, &config.profiles)
70+
configParseErr := yaml.Unmarshal(configContents, &config)
7171
if configParseErr != nil {
7272
log.Fatalf("Error in parsing config file: %s\n", configParseErr.Error())
7373
}
74+
75+
if len(config.Profiles) == 0 {
76+
log.Info("No profiles found, falling back to old config format.\n")
77+
configParseErr := yaml.Unmarshal(configContents, &config.Profiles)
78+
if configParseErr != nil {
79+
log.Fatalf("Error in parsing config file: %s\n", configParseErr.Error())
80+
}
81+
if len(config.Profiles) > 0 {
82+
log.Warning("WARNING: old depricated config format is used.\n")
83+
}
84+
}
7485
} else {
7586
log.Debug("No configuration file given\n")
7687
}
@@ -80,6 +91,14 @@ func StartService(configFile, address, profileName, MFA string, port int, fake b
8091
os.Remove(address)
8192
}()
8293

94+
if port == 0 {
95+
port = config.Port
96+
}
97+
98+
if port == 0 {
99+
port = 80
100+
}
101+
83102
// Startup the HTTP server and respond to requests.
84103
listener, err := net.ListenTCP("tcp", &net.TCPAddr{
85104
IP: net.ParseIP("169.254.169.254"),

cli-handler.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ func (h *CliHandler) RetrieveRole(ctx context.Context, in *pb.AssumeRoleRequest)
122122
return nil, err
123123
}
124124

125-
// TODO: FOO
126125
return &pb.StatusReply{
127126
Error: "",
128127
Role: h.credsManager.Role(),
@@ -137,9 +136,9 @@ func (h *CliHandler) RetrieveRole(ctx context.Context, in *pb.AssumeRoleRequest)
137136
// Config returns the current configuration
138137
func (h *CliHandler) Config(ctx context.Context, in *pb.Void) (*pb.ConfigReply, error) {
139138
res := &pb.ConfigReply{
140-
Profiles: make(map[string]*pb.Profile, len(h.config.profiles)),
139+
Profiles: make(map[string]*pb.Profile, len(h.config.Profiles)),
141140
}
142-
for name, profile := range h.config.profiles {
141+
for name, profile := range h.config.Profiles {
143142
res.Profiles[name] = &pb.Profile{
144143
AwsAccessKeyID: profile.AwsAccessKeyID,
145144
AwsSecretAccessKey: profile.AwsSecretAccessKey,

config.example

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,28 @@
11
---
2-
# The default profile is the profile that is loaded first, and the only role that
3-
# should need access keys. The default profile is *required*.
4-
#
5-
#
6-
# The default profile should only be able to assume roles. To assume these roles
7-
# the session should be authorized with a MFA token. With this set up your keys
8-
# will not be usable without multi factor authentication.
9-
default:
10-
# aws_access_key_id is required on the default profile
11-
aws_access_key_id: xxxxxxxxxxxxxxxxxxxx
12-
13-
# aws_secret_access_key is required on the default profile
14-
aws_secret_access_key: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
15-
16-
# role_session_name specifies the name used when assuming roles. Normaly a
17-
# sensible value is your username.
18-
role_session_name: yourusername
19-
20-
# region is used when connection to AWS and you can retrieve it from the
21-
# metadata service
22-
region: eu-west-1
23-
24-
# mfa_serial if present will prompt the user for an MFA when the service is
25-
# started. The MFA is then used for retrieving a session token.
26-
mfa_serial: arn:aws:iam::123456789012:mfa/yourusername
27-
28-
# This is an example of an profile that can be assumed with `limes profile admin`
29-
admin:
30-
# role_arn can be retrived from IAM
31-
role_arn: arn:aws:iam::123456789012:role/admin
32-
33-
# source_profile defines the profile to use when assuming this role
34-
source_profile: default
35-
36-
# assumable controls if it is possible to assume the role for the metadata service
37-
# otherwise it is only possible to use with 'run' and 'env' subcommand
38-
assumable: false
39-
region: eu-west-1
40-
41-
# This is an example of an profile that can be assumed with `limes profile readonly`
42-
readonly:
43-
role_arn: arn:aws:iam::123456789012:role/readonly
44-
source_profile: default
45-
region: eu-west-1
2+
port: 80
3+
profiles:
4+
# This defines a base profile, as it has AWS keys in it. Normaly a user like
5+
# this should only be allowd to assume other roles if MFA has been provided.
6+
# If an MFA serial is defined in the profile limes will promt for a MFA key
7+
# when needed.
8+
user:
9+
aws_access_key_id: xxxxxxxxxxxxxxxxxxxx
10+
aws_secret_access_key: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
11+
role_session_name: yourusername
12+
region: eu-west-1
13+
mfa_serial: arn:aws:iam::123456789012:mfa/yourusername
14+
15+
# This is an example of an profile that can not be assumed as
16+
# `protected: true` is defined on the profile. Only `limes run` and `limes env`
17+
# will be allowed.
18+
admin:
19+
role_arn: arn:aws:iam::123456789012:role/admin
20+
source_profile: user
21+
protected: true
22+
region: eu-west-1
23+
24+
# This is an example of an profile that can be assumed with `limes assume readonly`
25+
readonly:
26+
role_arn: arn:aws:iam::123456789012:role/readonly
27+
source_profile: user
28+
region: eu-west-1

0 commit comments

Comments
 (0)