brokenhandsio / vapor-oauth Goto Github PK
View Code? Open in Web Editor NEWOAuth2 Provider Library for Vapor
License: MIT License
OAuth2 Provider Library for Vapor
License: MIT License
I'm creating (with the new Fluent extensions) some OAuth clients with a Vapor controller and a POST request. Ideally, this POST request should allow a super user to create as many clients he'd like with different (and possibly multiple) grant types.
There could be situations with multiple grant types wher some flow would require, as per OAuth2 specifications, the presence of a client_secret. However, other don't. An example could be a single OAuth client with password + client_credentials grant types (I don't even know if it would make practical sense anyway, but there may be cases). The presence of a client_secret would require each REST call to the oauth endpoints (with any grant type) to provide it, otherwise the authenticateClient
function here will raise an exception and throw out an error.
Does it make sense?
Hi @0xTim and @marius-se,
This doesn't work:
.package(url: "https://github.com/brokenhandsio/vapor-oauth.git", branch: "1.0.0-beta.2")
try addProvider(VaporOAuth.Provider(codeManager: MyCodeManager(), tokenManager: MyTokenManager(), clientRetriever: MyClientRetriever(), authorizeHandler: MyAuthHandler(), userManager: MyUserManager(), validScopes: ["view_profile", "edit_profile"], resourceServerRetriever: MyResourceServerRetriever()))
This works:
app.lifecycle.use(
OAuth2(
codeManager: LiveCodeManger(),
tokenManager: tokenManager,
clientRetriever: StaticClientRetriever(clients: [someOAuthClient]),
authorizeHandler: LiveAuthorizeHandler(),
validScopes: ["admin"],
//resourceServerRetriever: LiveResourceServerRetriever(),
oAuthHelper: .local(
tokenAuthenticator: TokenAuthenticator(),
userManager: nil,
tokenManager: tokenManager
)
)
)
But oAuthHelper is not even mentioned in the documentation.
I’m seeing TokenRefreshTests.testErrorWhenRequestingScopeWithNoScopesOriginallyRequestedOnRefreshToken()
fail when I run locally, I wasn’t able to exactly figure out why it was happening though.
It looks like at one point travis was used for CI here.
This is the error message I'm getting when try to add your repo to my vapor project dependencies list.
Hi... Do you have plans to migrate to V3?
It would be great if a userInfo endpoint could also be included.
Test Suite 'Selected tests' started at 2023-12-09 15:51:36.975.
Test Suite 'VaporOAuthTests.xctest' started at 2023-12-09 15:51:36.975.
Test Suite 'TokenRefreshTests' started at 2023-12-09 15:51:36.975.
Test Case '-[VaporOAuthTests.TokenRefreshTests testErrorWhenRequestingScopeWithNoScopesOriginallyRequestedOnRefreshToken]' started.
2023-12-09T15:51:36+0100 info codes.vapor.request : request-id=50A454E1-AC5F-4652-ADD3-6247500FA98B [Vapor] POST /oauth/token/
/Users/kaeru/Library/Developer/Xcode/DerivedData/vapor-oauth-1.0.0-beta-ggpiumsqobyrmhfxbjcudwdlrdvz/SourcePackages/checkouts/swift-nio/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift:34: error: -[VaporOAuthTests.TokenRefreshTests testErrorWhenRequestingScopeWithNoScopesOriginallyRequestedOnRefreshToken] : failed: caught error: "keyNotFound(CodingKeys(stringValue: "error", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"error\", intValue: nil) (\"error\").", underlyingError: nil))"
Test Case '-[VaporOAuthTests.TokenRefreshTests testErrorWhenRequestingScopeWithNoScopesOriginallyRequestedOnRefreshToken]' failed (0.356 seconds).
Test Suite 'TokenRefreshTests' failed at 2023-12-09 15:51:37.331.
Executed 1 test, with 1 failure (1 unexpected) in 0.356 (0.356) seconds
Test Suite 'VaporOAuthTests.xctest' failed at 2023-12-09 15:51:37.331.
Executed 1 test, with 1 failure (1 unexpected) in 0.356 (0.356) seconds
Test Suite 'Selected tests' failed at 2023-12-09 15:51:37.332.
Executed 1 test, with 1 failure (1 unexpected) in 0.356 (0.357) seconds
Program ended with exit code: 1
222.7 [951/952] Compiling Vapor Application.swift
222.7 /build/.build/checkouts/vapor/Sources/Vapor/Request/Request.swift:5:1: remark: add '@preconcurrency' to suppress 'Sendable'-related warnings from module 'RoutingKit'
222.7 import RoutingKit
222.7 ^
222.7 @preconcurrency
222.7 /build/.build/checkouts/vapor/Sources/Vapor/Routing/Route.swift:2:1: remark: add '@preconcurrency' to suppress 'Sendable'-related warnings from module 'RoutingKit'
222.7 import RoutingKit
222.7 ^
222.7 @preconcurrency
223.8 [953/956] Compiling VaporOAuth EmptyAuthorizationHandler.swift
223.8 /build/.build/checkouts/vapor-oauth/Sources/VaporOAuth/RouteHandlers/AuthorizeGetHandler.swift:55:22: error: cannot find 'SecRandomCopyBytes' in scope
223.8 let status = SecRandomCopyBytes(kSecRandomDefault, 32, &bytes)
223.8 ^~~~~~~~~~~~~~~~~~
223.8 /build/.build/checkouts/vapor-oauth/Sources/VaporOAuth/RouteHandlers/AuthorizeGetHandler.swift:55:41: error: cannot find 'kSecRandomDefault' in scope
223.8 let status = SecRandomCopyBytes(kSecRandomDefault, 32, &bytes)
223.8 ^~~~~~~~~~~~~~~~~
223.8 /build/.build/checkouts/vapor-oauth/Sources/VaporOAuth/RouteHandlers/AuthorizeGetHandler.swift:57:25: error: cannot find 'errSecSuccess' in scope
223.8 guard status == errSecSuccess else {
223.8 ^~~~~~~~~~~~~
223.8 error: fatalError
223.8 /build/.build/checkouts/fluent/Sources/Fluent/Fluent+Sessions.swift:4:1: remark: add '@preconcurrency' to suppress 'Sendable'-related warnings from module 'FluentKit'
223.8 import FluentKit
223.8 ^
223.8 @preconcurrency
------
failed to solve: process "/bin/sh -c swift build -c release" did not complete successfully: exit code: 1
It would be great if the authorisation grant flow could also include PKCE
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.