Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set different clients to use different secret authentication #11

Closed
admover opened this issue Mar 23, 2018 · 4 comments
Closed
Labels

Comments

@admover
Copy link

admover commented Mar 23, 2018

hi,
How to set different clients to use different secret authentication, like freeradius.

@wojas
Copy link

wojas commented Mar 23, 2018

You can implement the SecretSource interface and set it as SecretSource:

https://godoc.org/layeh.com/radius#SecretSource

@ghost
Copy link

ghost commented Mar 24, 2018

Example implementation:

type HostSecrets struct {
	Secrets map[string][]byte
}

func (s *HostSecrets) RADIUSSecret(ctx context.Context, remoteAddr net.Addr) ([]byte, error) {
	host, _, err := net.SplitHostPort(remoteAddr.String())
	if err != nil {
		return nil, err
	}
	return s.Secrets[host], nil
}
h := &HostSecrets{
	Secrets: map[string][]byte{
		"::1":       []byte(`12345`),
		"127.0.0.1": []byte(`12345`),

		"10.0.0.2": []byte(`67890`),
	},
}

@ghost ghost closed this as completed Mar 24, 2018
@ghost ghost added the question label Mar 24, 2018
@admover
Copy link
Author

admover commented Mar 27, 2018

It's ok, thank you.
but, whether the secret is correct or not, it will be executed 'Handler'.

@duramen
Copy link

duramen commented Mar 27, 2019

Can I use network segment?
Example:

h := &HostSecrets{
	Secrets: map[string][]byte{
		"::1":       []byte(`12345`),
		"10.0.0.0/24": []byte(`67890`),
	},
}

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants