[FEATURE] Implement AuthMethod.Login#616
[FEATURE] Implement AuthMethod.Login#616marcin-krystianc merged 11 commits intoG-Research:masterfrom
AuthMethod.Login#616Conversation
| var authMethod = await _client.AuthMethod.Create(authMethodEntry); | ||
| Assert.NotNull(authMethod.Response); | ||
|
|
||
| var res = await _client.AuthMethod.Login(authMethod.Response.Name, null /* the application's bearer token */, WriteOptions.Default); |
There was a problem hiding this comment.
the application's bearer token: BearerToken, I think this is what's only missing now. @marcin-krystianc , I'd appreciate your help in how to get it. It's different from ServiceAccountJWT, I tried the latter, but the test failed with FAILED: AuthMethod_Login (30060ms) Consul.ConsulRequestException : Unexpected response, status code InternalServerError: Post "https://192.0.2.42:8443/apis/authentication.k8s.io/v1/tokenreviews": dial tcp 192.0.2.42:8443: i/o timeout
There was a problem hiding this comment.
See the working example here -> 1e9b329#diff-d42fd627833ffbeb33e7df7f767723fb02ec74bcbe13598f4715dd51a7abb2a4R153-R202
There was a problem hiding this comment.
ExportRSAPublicKeyPem() and CreateSignedJwt() aren't declared in the codebase: The name 'ExportRSAPublicKeyPem' does not exist in the current context[CS0103]
There was a problem hiding this comment.
ExportRSAPublicKeyPem()andCreateSignedJwt()aren't declared in the codebase:The name 'ExportRSAPublicKeyPem' does not exist in the current context[CS0103]
Implementation of these methods is available in the linked commit.
| AuthMethod = AuthMethod, | ||
| BearerToken = BearerToken | ||
| }; | ||
| var res = await _client.Post<LoginRequest, TokenEntry>("/v1/acl/login", loginRequest, writeOptions).Execute(ct).ConfigureAwait(false); |
There was a problem hiding this comment.
the PUT method is not allowed
| Task<WriteResult<TokenEntry>> Login(CancellationToken ct); | ||
| Task<WriteResult<TokenEntry>> Login(); | ||
| Task<WriteResult<TokenEntry>> Login(WriteOptions q, CancellationToken ct = default); | ||
| Task<WriteResult<TokenEntry>> Login(string AuthMethod, string BearerToken, WriteOptions writeOptions, CancellationToken ct = default); |
There was a problem hiding this comment.
Use lowercase for argument names:
| Task<WriteResult<TokenEntry>> Login(string AuthMethod, string BearerToken, WriteOptions writeOptions, CancellationToken ct = default); | |
| Task<WriteResult<TokenEntry>> Login(string authMethod, string bearerToken, WriteOptions writeOptions, CancellationToken ct = default); |
| var authMethod = await _client.AuthMethod.Create(authMethodEntry); | ||
| Assert.NotNull(authMethod.Response); | ||
|
|
||
| var res = await _client.AuthMethod.Login(authMethod.Response.Name, null /* the application's bearer token */, WriteOptions.Default); |
There was a problem hiding this comment.
See the working example here -> 1e9b329#diff-d42fd627833ffbeb33e7df7f767723fb02ec74bcbe13598f4715dd51a7abb2a4R153-R202
9dac6a2 to
b92f6f2
Compare
|
Should I exclude |
yes, please. |
There was a problem hiding this comment.
Since we are introducing a breaking change (it is fine since we know that functionality never worked anyway), let's remove that code as it is just an unnecessary noise.
marcin-krystianc
left a comment
There was a problem hiding this comment.
I've left a comment that we can use that opportunity to remove unnecessary code and unnecessary API surface. Looks good otherwise.
Description
Implement
AuthMethod.Login. See https://developer.hashicorp.com/consul/api-docs/acl#login-to-auth-methodRelated Issues
#615
Additional Context
Checklist
Please make sure to check the following before submitting your pull request: