@@ -10,10 +10,11 @@ import (
1010
1111 _ "authonomy/docs" // Swaggo generates docs in this package
1212
13+ "github.com/google/uuid"
1314 httpSwagger "github.com/swaggo/http-swagger"
1415)
1516
16- func Start (dbPath , secret , apiKey , port , ssiUrl string , reset bool ) {
17+ func Start (dbPath , secret , port , ssiUrl string , reset bool ) {
1718 // Initialize the data store (e.g., database connection)
1819 store , err := store .NewStore (dbPath , secret )
1920 if err != nil {
@@ -35,7 +36,8 @@ func Start(dbPath, secret, apiKey, port, ssiUrl string, reset bool) {
3536 log .Fatalf ("Failed to create policies: %v" , err )
3637 }
3738 }
38-
39+ // generate a new api key
40+ apiKey := uuid .New ().String ()
3941 fmt .Println ("=======================" )
4042 fmt .Println ("\033 [32m" , "------x-api-key------" , "\033 [0m" )
4143 fmt .Println ("\033 [32m" , apiKey , "\033 [0m" )
@@ -52,7 +54,7 @@ func Start(dbPath, secret, apiKey, port, ssiUrl string, reset bool) {
5254 credentialHandler := handlers .NewCredentialHandler (ssiService , store )
5355 authHandler := handlers .NewAuthHandler (ssiService , store )
5456 // Swagger endpoint
55- url := httpSwagger .URL ("http://localhost:8081 /swagger/doc.json" ) // The url pointing to API definition
57+ url := httpSwagger .URL ("http://localhost" + port + " /swagger/doc.json" )
5658 http .Handle ("/swagger/" , httpSwagger .Handler (
5759 url , //The url pointing to API definition
5860 ))
@@ -73,7 +75,7 @@ func Start(dbPath, secret, apiKey, port, ssiUrl string, reset bool) {
7375 http .HandleFunc ("/revoke-credential" , m .ChainMiddleware (m .XApiKeyMiddleware , m .LoggingMiddleware )(credentialHandler .RevokeOAuthCredential ))
7476
7577 // application itself access
76- http .HandleFunc ("/validate -access" , m .ChainMiddleware (m .LoggingMiddleware )(authHandler .VerifyAccess ))
78+ http .HandleFunc ("/verify -access" , m .ChainMiddleware (m .LoggingMiddleware )(authHandler .VerifyAccess ))
7779 http .HandleFunc ("/issue-credential" , m .ChainMiddleware (m .EnableCORS , m .LoggingMiddleware )(credentialHandler .IssueOAuthCredential ))
7880 // application user access
7981 http .HandleFunc ("/callback/" , m .ChainMiddleware (m .EnableCORS , m .LoggingMiddleware )(callbackHandler .HandleCallback ))
@@ -82,7 +84,7 @@ func Start(dbPath, secret, apiKey, port, ssiUrl string, reset bool) {
8284
8385 http .HandleFunc ("/get-access-token" , m .ChainMiddleware (m .LoggingMiddleware )(authHandler .GetAccessToken ))
8486 http .HandleFunc ("/request-access" , m .ChainMiddleware (m .LoggingMiddleware )(authHandler .RequestAccess ))
85-
87+ http . HandleFunc ( "/get-access-list" , m . ChainMiddleware ( m . LoggingMiddleware )( authHandler . GetAccessList ))
8688 // static web page for access_token
8789 fs := http .FileServer (http .Dir ("web" ))
8890 http .Handle ("/web/" , http .StripPrefix ("/web/" , fs ))
0 commit comments